fork download
  1. import std.stdio;
  2. import std.string;
  3. import std.range;
  4. import std.conv;
  5.  
  6. void main(string[] args)
  7. {
  8. foreach(input; stdin.byLine)
  9. {
  10. int cidr = input.strip.to!int;
  11. if(cidr > 32)
  12. {
  13. writeln("Too big");
  14. continue;
  15. }
  16. string mask = '1'.repeat.take(cidr).chain('0'.repeat.take(32 - cidr)).to!string;
  17. cidr.writeln;
  18. mask.writeln;
  19. mask.to!(long)(2).writeln;
  20. writeln;
  21. }
  22. }
Success #stdin #stdout 0s 14976KB
stdin
8
	16
	3
	21
	33
	32
stdout
8
11111111000000000000000000000000
4278190080

16
11111111111111110000000000000000
4294901760

3
11100000000000000000000000000000
3758096384

21
11111111111111111111100000000000
4294965248

Too big
32
11111111111111111111111111111111
4294967295