C++ to Python
签到题
输出''('、')'、 ','及数字
#include <bits/stdc++.h>
using namespace std;
#define js ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define debug system("pause")
#define endl "\n"
int main(){
int T;cin>>T;
string s,ans;
while(T--){
cin>>s;
ans.clear();
for(int i=0;i<s.length();i++)
if(s[i]=='(' or s[i]==')' or s[i]==',' or s[i]=='-' or s[i]>='0' and s[i]<='9'){
ans+=s[i];
}
cout<<ans<<endl;
}
debug;
}
ShuanQ
数论题
输出P*Q-1的质因子,并要求其大于max(P,Q,E)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
int T;cin>>T;
ll P,Q,E;
while(T--){
cin>>P>>Q>>E;
ll maxx=max(P,Q);
maxx=max(maxx,E);
ll u = P*Q-1;
for(ll i=2;i<=sqrt(u);i++){
while(u%i==0) u/=i;
}
if(u>maxx) cout<<E*Q%u<<endl;
else cout<<"shuanQ\n";
}
}