pta - 1132 Cut Integer
生活随笔
收集整理的這篇文章主要介紹了
pta - 1132 Cut Integer
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
判斷這個偶數長度的數平分長度后再乘起來能否被原數整除
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; typedef long long ll; int main() {int t;ll n;ios::sync_with_stdio(0);cin>>t;while(t--){bool f=0;cin>>n;int len=0;int tmp = n;while(tmp){tmp/=10;len++;}int a;a = n%((int)pow(10,len/2));tmp = n/((int)pow(10,len/2));if(a!=0&&n%a==0){n/=a;if(tmp!=0&&n%tmp==0)f=1;}if(f)puts("Yes");else puts("No");}return 0; }開始寫的時候碰到了浮點錯誤
原來是出現了除以0的情況
注意取余除法 還有 數據溢出導致除0的情況
總結
以上是生活随笔為你收集整理的pta - 1132 Cut Integer的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 罗技鼠标G304驱动与讲解(其余类型驱动
- 下一篇: 部分格式文件解释以及万能文件查看器下载