日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

PAT甲级1132 Cut Integer:[C++题解]

發(fā)布時間:2025/4/5 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 PAT甲级1132 Cut Integer:[C++题解] 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

文章目錄

      • 題目分析
      • 題目來源

題目分析



來源:acwing

分析:使用string讀入,然后stoi轉(zhuǎn)換成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/

總結(jié)

以上是生活随笔為你收集整理的PAT甲级1132 Cut Integer:[C++题解]的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。