__int64 and long long int are often confronted with large integers when doing ACM problems. The commonly used built-in integer types are often too small: the long and int ranges are [ -2^31,2^31], or -2147483648~2147483647. The unsigned range is [0,2^32], which is 0~4294967295. In other words, the regular 32-bit integer can only handle numbers below 4 billion.
What about the numbers that are larger than 4 billion? This will use the C + + 64-bit extension. Different compilers differ in the extension of 64-bit integers. Based on the needs of ACM, only the extensions of the VC6.0 and g++ compilers are described below.
VC VC6.0 64-bit integers are called __int64 and unsigned __int64, respectively, the range is [ -2^63, 2^63) and [0,2^64], that is -9223372036854775808~ 9223372036854775807 with 0~18446744073709551615 (about 180 billion). The operation of 64-bit integers is basically the same as a 32-bit integer, which supports arithmetic and bitwise operations. A 32-bit integer is implicitly converted to a 64-bit integer when a 64-bit and 32-bit blending operation is performed. However, the VC input and output compatibility with __int64 is not very good, if you write down such a piece of code:
1 __int64 A;
2 Cin >> A;
3 cout << A;
Then, on the 2nd line, you receive "Error C2679:binary >>": no operator defined which takes a right-hand operand of type ' __int64 ' (or the Re is no acceptable conversion) "error in 3rd row received" Error C2593: ' operator << ' is ambiguous ' errors. Is it not possible to enter and output it? Of course not, you can use the C notation:
scanf ("%i64d", & A);
printf ("%i64d", a); You can enter the output correctly. When using unsigned __int64, change "i64d" to "I64u".
OJ typically use the g++ compiler. Its 64-bit extension is different from VC, which are called long long and unsigned long long. The processing scale is the same as the usage except the input and output. For the input and output, it is better than VC extension. You can use both
1 long long A;
2 Cin >> A;
3 cout << A; You can also use
scanf ("%lld", & A);
printf ("%lld", a);
When using unsigned numbers, change "%lld" to "%llu".
Finally, I add: As a special case, if you are using the dev-c++ g++ compiler, it uses "%i64d" rather than "%LLD".
is transferred from a Netizen's space, unfortunately Baidu does not let write the connection address, eh, pity, but recommend his name, dust-laden pavilion. Here you are.
Need Baidu a bit, maybe you can find him from: http://hi.baidu.com/lyloric/blog/item/21c1e48b2baf40e3f11f3649.html