1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include <iostream> using namespace std; template<unsigned int n> struct Factorial { enum { value = n * Factorial<n-1>::value}; }; template<> struct Factorial<0> { enum {value = 1}; }; template<int factorial> struct _{ operator char() { return factorial + 256; } }; //always overflow int main() { char(_<Factorial<5>::value>()); return 0; } |
I2luY2x1ZGUgPGlvc3RyZWFtPgogCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiAKdGVtcGxhdGU8dW5zaWduZWQgaW50IG4+CnN0cnVjdCBGYWN0b3JpYWwgewogICAgZW51bSB7IHZhbHVlID0gbiAqIEZhY3RvcmlhbDxuLTE+Ojp2YWx1ZX07Cn07CiAKdGVtcGxhdGU8PgpzdHJ1Y3QgRmFjdG9yaWFsPDA+IHsKICAgIGVudW0ge3ZhbHVlID0gMX07Cn07Cgp0ZW1wbGF0ZTxpbnQgZmFjdG9yaWFsPiAKc3RydWN0IF97IG9wZXJhdG9yIGNoYXIoKSB7IHJldHVybiBmYWN0b3JpYWwgKyAyNTY7IH0gfTsgLy9hbHdheXMgb3ZlcmZsb3cKaW50IG1haW4oKSB7CiAgICAgICAgY2hhcihfPEZhY3RvcmlhbDw1Pjo6dmFsdWU+KCkpOwogICAgICAgIHJldHVybiAwOwp9Cg==
prog.cpp: In member function ‘_<factorial>::operator char() [with int factorial = 120]’: prog.cpp:18: instantiated from here prog.cpp:16: warning: overflow in implicit constant conversion
-
upload with new input
-
result: Success time: 0s memory: 2720 kB returned value: 0


