PAT甲级1132 Cut Integer:[C++题解]
生活随笔
收集整理的这篇文章主要介绍了
PAT甲级1132 Cut Integer:[C++题解]
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
文章目录
- 题目分析
- 题目来源
题目分析
来源:acwing
分析:使用string读入,然后stoi转换成int型。
ac代码
#include<bits/stdc++.h> using namespace std;bool check(int a,int b, int c){long long res = b *c;if(a % res == 0) return true;return false; }int main(){int n;cin >> n;while(n--){string a;cin >> a;int len = a.size();int num = stoi(a);int b = stoi(a.substr(0,len/2));int c = stoi(a.substr(len/2));if( b && c && check(num,b,c)) cout<<"Yes"<<endl;else cout<<"No"<<endl;} }
下面是使用了if(b && c && num %b == 0 && num %c == 0)这是不对的。
题目来源
PAT甲级1132 Cut Integer
https://www.acwing.com/problem/content/1627/
总结
以上是生活随笔为你收集整理的PAT甲级1132 Cut Integer:[C++题解]的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: PAT甲级1109 Group Phot
- 下一篇: PAT甲级1140 Look-and-s