为什么用unsigned long long无法通过,而使用long long就过了?

P1634 禽兽的传染病

```cpp #include <bits/stdc++.h> using namespace std; int main(){ unsigned long long int x,n,s=1; cin>>x>>n; x++; for(int i=1;i<=n;i++)s*=x; cout<<s; return 0; } 这个程序就过了,可能你输入输出格式不太对 ```
by Amphetamine @ 2017-05-01 21:00:03


unsigned long long的输出格式为"%llu"
by Farblos @ 2017-05-21 21:40:01


@[陆仁贾](/space/show?uid=29883) 明明是%lld
by justforfun @ 2017-06-04 14:26:22


@[木木666](/space/show?uid=37243) 那是long long
by Farblos @ 2017-06-04 17:27:35


```cpp #include<iostream> #include<cstdio> #include<cstring> using namespace std; unsigned long long x,n,a,i; int main(){ scanf("%lld %lld",&x,&n); a=1; for(i=1;i<=n;i++){ a=a*(x+1); } printf("%lld",a); return 0; }//%lld可以过 ```
by justforfun @ 2017-06-05 22:43:09


@[陆仁贾](/space/show?uid=29883)
by justforfun @ 2017-06-05 22:50:47


@[木木666](/space/show?uid=37243) 并不是输出格式必须与变量类型相同,scanf相当于以与输出格式相同的变量类型输出,也就是说就算你用%d也能输出,只不过不大于2^31-1(int类型最大值);
by Farblos @ 2017-06-09 18:50:18


|