求助大佬
  • 板块学术版
  • 楼主_TLJYatm_
  • 当前回复6
  • 已保存回复6
  • 发布时间2021/9/22 20:42
  • 上次更新2023/11/4 05:52:55
查看原帖
求助大佬
45199
_TLJYatm_楼主2021/9/22 20:42
#include<cstdio>
#include<iostream>
namespace IO{
    char buf[1000010],*cur=buf+1000010;
    inline char getc(){
        (cur==buf+1000010)?fread(cur=buf,1,1000010,stdin):0;
        return *cur++;
    }
    char buff[1000010],*curr=buff;
    inline void flush(){
        fwrite(buff,1,curr-buff,stdout);
    }
    inline void putc(const char &ch){
        (curr==buff+1000010)?fwrite(curr=buff,1,1000010,stdout):0;
        *curr++=ch;
    }
  
    inline void rdi(int &x){
        x=0;char ch=getc();int f=1;
        while(ch<'0'||ch>'9'){
            if(ch=='-')f=-1;
            ch=getc();
        }
        while(ch>='0'&&ch<='9'){
            x=x*10+ch-'0';
            ch=getc();
        }
        x*=f;
    }
    
    inline void rdl(long long &x){
        x=0;char ch=getc();long long f=1;
        while(ch<'0'||ch>'9'){
            if(ch=='-')f=-1;
            ch=getc();
        }
        while(ch>='0'&&ch<='9'){
            x=x*10+ch-'0';
            ch=getc();
        }
        x*=f;
    }
 
    char st[60];int tp;
    void PT(long long x){
        if(x==0)putc('0');
        else{
            while(x>0){
                st[++tp]=x%10+'0';
                x/=10;
            }
        }
        while(tp)putc(st[tp--]);
    }
}
using IO::getc;
using IO::putc;
using IO::rdi;
using IO::rdl;
using IO::PT;
using namespace std;
long long n;
int k,t;
long long a[1<<16];
int main(){
	freopen("prime.in","r",stdin);
	freopen("prime.out","w",stdout); 
	long long p[16]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53};
	for (int i=1; i<(1 << 16); i++){
		long long c=1; int sum=0;
		for (int j=0; j<16; j++)
		if (i & (1 << j)){
			c*=p[j]; 
			sum++;
		}
		if (sum % 2==0) a[i]=c;
		else a[i]=-c;
	}
	rdi(t);
	while (t--){
		rdl(n); rdi(k);
		long long m=n;
		for (int i=1; i<(1 <<k); i++) n+=m/a[i];		
		PT(n);
	}
	return 0;
}

这样写以后怎么在输出后回车啊,printf好像用不了

2021/9/22 20:42
加载中...