QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#78256#5503. Euclidean AlgorithmCrysflyCompile Error//C++111.5kb2023-02-17 15:12:572023-02-17 15:12:58

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-17 15:12:58]
  • 评测
  • [2023-02-17 15:12:57]
  • 提交

answer

// what is matter? never mind. 
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
typedef iint int;
#define int long long
using namespace std;
inline int read()
{
	char c=getchar();int x=0;bool f=0;
	for(;!isdigit(c);c=getchar())f^=!(c^45);
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
	if(f)x=-x;return x;
}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 10000005
#define inf 0x3f3f3f3f

int n;

iint pri[maxn],tot;
bool vis[maxn];
iint d[maxn];
void sieve(int n){
	vis[1]=1;
	d[1]=1;
	For(i,2,n){
		if(!vis[i])pri[++tot]=i,d[i]=2;
		For(j,1,tot){
			int x=i*pri[j];
			if(x>n)break;
			vis[x]=1;
			if(i%pri[j]==0){
				d[x]=d[i]*2-d[i/pri[j]];
				break;
			}
			d[x]=d[i]*2;
		}
	}
	For(i,1,n)d[i]+=d[i-1];
}

int calc(int n){
	if(n<=10000004) return d[n]; 
	int res=0;
	for(int l=1,r;l<=n;l=r+1){
		r=n/(n/l);
		res+=(r-l+1)*(n/l);
	}
	return res;
}

int calc1(int n){
	int res=0; 
	for(int l=1,r;l<=n;l=r+1){
		r=n/(n/l);
	//	cout<<"calc1 "<<l<<" "<<r<<"\n"; 
		res+=(r-l+1)*calc(n/l-1);
	}
	return res;
}

void work()
{
	n=read();
	int res=calc1(n);
	cout<<res<<'\n';
}

signed main()
{
	sieve(1e7+5);
	int T=read();
	while(T--)work();
	return 0;
}
/*

10 17
3 10 31

G 4G 7G 10G
G 3G 5G 7G 9G
G 2G 3G 4G 5G


4
A
QUERY B
ADD BBABBBBAAB
QUERY B
*/

Details

answer.code:5:9: error: ‘iint’ does not name a type; did you mean ‘uint’?
    5 | typedef iint int;
      |         ^~~~
      |         uint
answer.code:28:1: error: ‘iint’ does not name a type; did you mean ‘uint’?
   28 | iint pri[maxn],tot;
      | ^~~~
      | uint
answer.code:30:1: error: ‘iint’ does not name a type; did you mean ‘uint’?
   30 | iint d[maxn];
      | ^~~~
      | uint
answer.code: In function ‘void sieve(long long int)’:
answer.code:33:9: error: ‘d’ was not declared in this scope
   33 |         d[1]=1;
      |         ^
answer.code:35:28: error: ‘pri’ was not declared in this scope; did you mean ‘pii’?
   35 |                 if(!vis[i])pri[++tot]=i,d[i]=2;
      |                            ^~~
      |                            pii
answer.code:35:34: error: ‘tot’ was not declared in this scope
   35 |                 if(!vis[i])pri[++tot]=i,d[i]=2;
      |                                  ^~~
answer.code:36:25: error: ‘tot’ was not declared in this scope
   36 |                 For(j,1,tot){
      |                         ^~~
answer.code:3:38: note: in definition of macro ‘For’
    3 | #define For(i,a,b) for(int i=(a);i<=(b);++i)
      |                                      ^
answer.code:37:33: error: ‘pri’ was not declared in this scope; did you mean ‘pii’?
   37 |                         int x=i*pri[j];
      |                                 ^~~
      |                                 pii
answer.code: In function ‘long long int calc(long long int)’:
answer.code:51:32: error: ‘d’ was not declared in this scope
   51 |         if(n<=10000004) return d[n];
      |                                ^