期望得分:100+100+0=200

实际得分:5+0+0=5

 

2017北京国庆刷题Day4 afternoon

每加入一个数,x的因数位置++

注意:根号x枚举时,如果x是完全平方数,根号x会重复累计2次,要减去

考场上没减,5分 /(ㄒoㄒ)/~~

#include<cmath>
#include<cstdio>
#include<iostream>
using namespace std;
#define N 40001
int sum[N];
void read(int &x)
{
    x=0; char c=getchar();
    while(!isdigit(c)) c=getchar();
    while(isdigit(c)) { x=x*10+c-'0'; c=getchar(); }
}
int main()
{
    freopen("a.in","r",stdin);
    freopen("a.out","w",stdout);
    int n,ans=0;
    read(n);
    int x,y,z;
    while(n--)
    {
        read(x); read(y);
        if(x==1) 
        {
            z=sqrt(y);
            for(int i=1;i<=z;i++)
                if(y%i==0) sum[i]++,sum[y/i]++; 
            if(z*z==y) sum[z]--; 
        }
        else ans^=sum[y];
    }
    printf("%d",ans);
}
View Code

相关文章:

  • 2021-11-13
  • 2021-07-30
  • 2021-10-25
  • 2021-12-02
  • 2021-10-29
  • 2021-11-04
  • 2021-09-16
  • 2022-01-24
猜你喜欢
  • 2021-10-12
  • 2021-07-14
  • 2021-12-11
  • 2022-02-08
  • 2021-07-30
  • 2022-02-11
  • 2022-02-13
相关资源
相似解决方案