J A+B problem
题目解读:签到题。分别将两个数逆序相加再逆序。
AC代码:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll reverse(ll a)
{
ll s=0;
while(a)
{
s=s*10+a%10;
a/=10;
}
return s;
}
int main()
{
int t;cin>>t;
while(t--)
{
ll a,b;cin>>a>>b;
a=reverse(a)+reverse(b);
a=reverse(a);
cout<<a<<endl;
}
return 0;
}
D Number
题目解读:签到题。给一个位数n和一个素数p(是不是素数不影响解题),输出一个位数为n且能整除素数p的数,多个的话可以输出任意一个。
AC代码:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,p;cin>>n>>p;
int t=p,s=0;
while(t)
{
s++;
t/=10;
}
if(s>n)
cout<<"T_T"<<endl;
else
{
cout<<p;
for(int i=s;i<n;i++)
cout<<0;
cout<<endl;
}
return 0;
}