目录
诡异的因数
#include<bits/stdc++.h>
using namespace std;
void solve()
{
int n; cin>>n;
int cnt=0;
for(int i=1;i<=n/i;i++)
{
if(n%i==0)
{
cnt++;
if(n/i!=i) cnt++;
}
}
cout<<cnt<<endl;
}
int main(void)
{
int t; cin>>t;
while(t--) solve();
return 0;
}
表单
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,m;
int a[N],cnt;
map<string,int>mp;
char s[100005];
int main(void)
{
cin>>n>>m;
for(int i=0;i<n;i++)
{
scanf("%s",s);
if(mp[s]) cnt++;
mp[s]++;
}
while(m--)
{
int op; scanf("%d",&op);
if(op==1)
{
scanf("%s",s);
if(mp[s]) cnt++;
mp[s]++;
}else
{
cout<<cnt<<endl;
cnt=0;
}
}
return 0;
}
分数的运算
#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
LL xx1,yy1,xx2,yy2;
LL gcd(LL a,LL b) {return b?gcd(b,a%b):a;}
void f1()
{
LL a=xx1*yy2+xx2*yy1;
LL b=yy1*yy2;
int flag=1;
if(a<0) flag=flag*(-1);
if(b<0) flag=flag*(-1);
a=labs(a),b=labs(b);
LL temp=gcd(a,b);
if(a==0||b==0)
{
printf("0 0\n");
}
else printf("%lld %lld\n",flag*a/temp,b/temp);
}
void f2()
{
LL a=xx1*yy2-xx2*yy1;
LL b=yy1*yy2;
int flag=1;
if(a<0) flag=flag*(-1);
if(b<0) flag=flag*(-1);
a=labs(a),b=labs(b);
LL temp=gcd(a,b);
if(a==0||b==0)
{
printf("0 0\n");
}
else printf("%lld %lld\n",flag*a/temp,b/temp);
}
void f3()
{
LL a=xx1*xx2;
LL b=yy1*yy2;
int flag=1;
if(a<0) flag=flag*(-1);
if(b<0) flag=flag*(-1);
a=labs(a),b=labs(b);
LL temp=gcd(a,b);
if(a==0||b==0)
{
printf("0 0\n");
}
else printf("%lld %lld\n",flag*a/temp,b/temp);
}
void f4()
{
LL a=xx1*yy2;
LL b=yy1*xx2;
int flag=1;
if(a<0) flag=flag*(-1);
if(b<0) flag=flag*(-1);
a=labs(a),b=labs(b);
LL temp=gcd(a,b);
if(a==0||b==0)
{
printf("0 0\n");
}
else printf("%lld %lld\n",flag*a/temp,b/temp);
}
int main(void)
{
cin>>xx1>>yy1>>xx2>>yy2;
f1(),f2(),f3(),f4();
return 0;
}