/ tabris /

记录详情

Accepted

/in/foo.cc:43:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 #pragma comment(linker,"/STACK:102400000,102400000")
 
# 状态 耗时 内存占用
#1 Accepted 5ms 1.578 MiB
#2 Accepted 5ms 1.586 MiB
#3 Accepted 5ms 1.465 MiB
#4 Accepted 5ms 1.57 MiB
#5 Accepted 5ms 1.582 MiB
#6 Accepted 5ms 1.586 MiB
#7 Accepted 4ms 1.465 MiB
#8 Accepted 5ms 1.582 MiB
#9 Accepted 6ms 1.578 MiB
#10 Accepted 24ms 1.582 MiB

代码

#include <bits/stdc++.h>
typedef long long int LL;
using namespace std;

const int N = 1e6+7;
const int MOD = 1e9+7;

#define DEBUG true
#define DATA 1
#define STD 2
#define VALID 3

int random(int x){
    return (LL)rand()%rand()%x;
}


void stdinout(int k, int status){
    string file_in  = "testcase/" + to_string(k) + ".in";
    string file_out = "testcase/" + to_string(k) + ".out";
    if(1==status){
        freopen(file_in.c_str(), "w" ,stdout);
    }
    else if(2==status){
        freopen(file_in.c_str(), "r", stdin);
        freopen(file_out.c_str(), "w", stdout);
    }
    else if(3==status){
        freopen(file_in.c_str(), "r", stdin);
    }
}

#define sfi(a) scanf("%d",&a)
#define sfd(a) scanf("%lf",&a)
#define sfl(a) scanf("%lld",&a)
#define sfs(a) scanf("%s",a)
 
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define dwn(i,b,a) for(int i=int(b-1);i>=int(a);--i)
 
#define mem(a,p) memset(a,p,sizeof(a))
 
#pragma comment(linker,"/STACK:102400000,102400000")
 

typedef unsigned UINT;
typedef unsigned long long ULL;
 
const int MAXN=100000;
 
bool vis[MAXN+5];
int prime[MAXN+5],cnt;
int phi[MAXN+5];
int mi[MAXN+5];
int muda[MAXN+5];
 
void init()
{
    memset(vis,0,sizeof(vis));
    phi[1]=1;
    mi[1]=1;
    cnt=0;
    for(int i=2;i<=MAXN;i++)
    {
        if(!vis[i])
        {
            prime[cnt++]=i;
            phi[i]=i-1;
            mi[i]=-1;
        }
        for(int j=0;j<cnt&&i*prime[j]<=MAXN;j++)
        {
            vis[i*prime[j]]=true;
            if(i%prime[j])
            {
                phi[i*prime[j]]=phi[i]*(prime[j]-1);
                mi[i*prime[j]]=-mi[i];
            }
            else
            {
                phi[i*prime[j]]=phi[i]*prime[j];
                mi[i*prime[j]]=0;
                break;
            }
        }
    }

    memset(muda,0,sizeof(muda));
    for(int i=1;i<=MAXN;i++)
    {
        for(int j=1;j*i<=MAXN;j++)
            muda[j*i]+=i*mi[i];
    }
}
 
 
int run()
{
    init();
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n;
        scanf("%d\n",&n);
        printf("%d\n",muda[n]);
    }
    return 0;
}

void work(){
    for(int i=1;i<=10;i++){
        stdinout(i, STD);
        run();
    }
}

int main(){
    srand((unsigned)time(NULL));
    run();
    return 0;
}

信息

递交者
类型
递交
语言
C++
递交时间
2019-06-10 22:44:30
评测时间
2019-06-10 22:45:31
评测机
分数
100
总耗时
72ms
峰值内存
1.586 MiB