QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#621310 | #1907. 博弈 | kgqy | Compile Error | / | / | C++14 | 2.1kb | 2024-10-08 12:37:12 | 2024-10-08 12:37:14 |
Judging History
你现在查看的是最新测评结果
- [2024-10-08 15:30:08]
- hack成功,自动添加数据
- (/hack/942)
- [2024-10-08 12:37:14]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2024-10-08 12:37:12]
- 提交
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read(){
int w=0;char ch=getchar();
while(!isdigit(ch)) ch=getchar();
while(isdigit(ch)) w=w*10+ch-'0',ch=getchar();
return w;
}
int cnt1[100005],cnt2[100005],cnt[100005];
int n=100000;
vector<int> vec[100005];
int ton[100005];
int pri[100005],tot;
void init(){
cnt2[2]=1;
pri[++tot]=2;
vec[2].push_back(2);
for(int i=3;i<=n;i++){
int vs=0;
int nw=i;
while(!(nw&1)) cnt2[i]++,nw>>=1,vs=1,vec[i].push_back(2);
for(int j=2;j<=tot&&pri[j]*pri[j]<=nw;j++){
int p=pri[j];
while(!(nw%p)) nw/=p,cnt1[i]++,vs=1,vec[i].push_back(p);
}
if(!vs) pri[++tot]=i;
if(nw>1) cnt1[i]++,vec[i].push_back(nw);
}
for(int i=2;i<=n;i++){
int fs=vec[i][vec[i].size()-1];
cnt[i]=cnt[i/fs]*fs+1;
}
}
int prea[100005],preb[100005];
int sg[100005];
main(){
init();
n=read();
int q=read();
for(int i=1;i<=n;i++){
int na=read(),nb=read(),nw=read(),nh=read();
if(!na&&!nb){
int p1=cnt1[nw]+cnt2[nw],p2=cnt1[nh]+cnt2[nh];
if(p1>p2){
int del=p1-p2,pp=0;
for(int i=vec[nw].size()-del;i<vec[nw].size();i++){
int p=vec[nw][i];
pp=pp*p+1;
}
prea[i]=pp;
}
if(p1<p2){
int del=p2-p1,pp=0;
for(int i=vec[nh].size()-del;i<vec[nh].size();i++){
int p=vec[nh][i];
pp=pp*p+1;
}
prea[i]=pp;
}
}
if(na&&!nb){
prea[i]=cnt[nw]*nh;
sg[i]=cnt1[nh]+(cnt2[nh]>0);
}
if(!na&&nb){
preb[i]=cnt[nh]*nw;
sg[i]=cnt1[nw]+(cnt2[nw]>0);
}
if(na&&nb){
sg[i]=(cnt1[nw]^cnt1[nh])+(cnt2[nw]+cnt2[nh]>0);
}
// printf("sunzh %d %d %d %d\n\n",i,prea[i],preb[i],sg[i]);
}
for(int i=2;i<=n;i++) prea[i]+=prea[i-1],preb[i]+=preb[i-1],sg[i]^=sg[i-1];
while(q--){
int ql=read(),qr=read();
int na=prea[qr]-prea[ql-1];
int nb=preb[qr]-preb[ql-1];
printf("nab %d %d\n",na,nb);
// printf("lr %d %d\n",ql,qr);
if(na>nb) putchar("Y");
if(na<nb) putchar("N");
if(na==nb){
int nsg=sg[qr]^sg[ql-1];
putchar(nsg?"Y":"N");
}
// puts("");
}
}
/*
3
0 0 3 3
0 0 1 2
0 0 2 1
1
1 3
*/
详细
answer.code:37:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type] 37 | main(){ | ^~~~ answer.code: In function ‘int main()’: answer.code:80:30: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=] 80 | printf("nab %d %d\n",na,nb); | ~^ ~~ | | | | int long long int | %lld answer.code:80:33: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘long long int’ [-Wformat=] 80 | printf("nab %d %d\n",na,nb); | ~^ ~~ | | | | int long long int | %lld answer.code:82:35: error: invalid conversion from ‘const char*’ to ‘int’ [-fpermissive] 82 | if(na>nb) putchar("Y"); | ^~~ | | | const char* In file included from /usr/include/stdio.h:864, from /usr/include/c++/13/cstdio:42, from /usr/include/c++/13/ext/string_conversions.h:45, from /usr/include/c++/13/bits/basic_string.h:4097, from /usr/include/c++/13/string:54, from /usr/include/c++/13/bitset:52, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52, from answer.code:1: /usr/include/x86_64-linux-gnu/bits/stdio.h:82:14: note: initializing argument 1 of ‘int putchar(int)’ 82 | putchar (int __c) | ~~~~^~~ answer.code:83:35: error: invalid conversion from ‘const char*’ to ‘int’ [-fpermissive] 83 | if(na<nb) putchar("N"); | ^~~ | | | const char* /usr/include/x86_64-linux-gnu/bits/stdio.h:82:14: note: initializing argument 1 of ‘int putchar(int)’ 82 | putchar (int __c) | ~~~~^~~ answer.code:86:36: error: invalid conversion from ‘const char*’ to ‘int’ [-fpermissive] 86 | putchar(nsg?"Y":"N"); | ~~~^~~~~~~~ | | | const char* /usr/include/x86_64-linux-gnu/bits/stdio.h:82:14: note: initializing argument 1 of ‘int putchar(int)’ 82 | putchar (int __c) | ~~~~^~~