dalao救命啊!

P2955 [USACO09OCT] Even? Odd? G

大哥,这是高精度啊。。。QAQ
by LCGUO @ 2019-11-12 13:22:52


@[tt100723](/user/252401) 1 <= I <= 10^60
by k2saki @ 2019-11-12 13:23:20


@[tt100723](/user/252401) 用字符串!
by k2saki @ 2019-11-12 13:23:35


@[tt100723](/user/252401) 你一边输入一边测试就能把数组省掉
by JasonZRY @ 2019-11-12 13:25:50


像这样 ``` #include<bits/stdc++.h> using namespace std; string s; int n,a,l; int main(){ scanf("%d",&n); for(int i=1;i<=n;i++){ cin>>s; l=s.size(); a=s[l-1]-'0'; if(a%2)printf("odd\n"); else printf("even\n"); } } ```
by JasonZRY @ 2019-11-12 13:30:02


什么意思?我不懂。因为我才4年级。 题目没说要高精度。
by xxx听取AC声一片 @ 2019-11-13 07:44:14


各位大佬,是这样吗? ```cpp #include<bits/stdc++.h> using namespace std; long long n,a; int main() { cin>>n; for(int i=1;i<=n;i++) { cin>>a; if(a%2==0) cout<<"even"<<endl; if(a%2==1) cout<<"odd"<<endl; } return 0; } ```
by xxx听取AC声一片 @ 2019-11-13 07:48:08


@[tt100123](/user/252401) 不对,你的i是int型的,而n是long long型的,如果n大一点,你的i肯定加不到n那里去的。 而且这道题不能用long long(会炸),得用字符串。 ```cpp #include <iostream> #include <string> #define Y "even\n" #define N "odd\n" using namespace std; string n; string s; int main() { cin >> n; while(cin >> s){ if((s[s.length()-1]-48)%2==0) cout << Y; else cout << N; } return 0; } ```
by Return_ @ 2020-01-27 17:09:45


@[v果宝v](/user/187259) 不需要用高精度
by Return_ @ 2020-01-27 17:10:10


对,没有必要 ```cpp #include<iostream> using namespace std; int main() { int a; string n; cin >> a; while(cin >> n) { if(n[n.size() - 1] % 2 == 1) { cout << "odd" << endl; } else { cout << "even" << endl; } } return 0; } ```
by chenyitian @ 2021-03-04 22:34:54


|