Submission #65004
ソースコード
ステータス
コンパイルメッセージ
./Main.cpp:2:22: error: stray ‘#’ in program
using namespace std; #define rep(i,a,n) for(int i=(a);i<(n);++i) #define int int64_t signed main(){ int n; cin>>n; int cnt = 0,ans; rep(i,0,n){ int a; cin>>a; if(i == 0) ans = abs(i+1 - a); else ans = __gcd(ans,abs(i+1 - a); if(a == i+1) ++cnt;} if(cnt == n) cout<<n-1<<'\n';else cout<<ans<<'\n'; return 0;}
^
./Main.cpp:2:66: error: stray ‘#’ in program
using namespace std; #define rep(i,a,n) for(int i=(a);i<(n);++i) #define int int64_t signed main(){ int n; cin>>n; int cnt = 0,ans; rep(i,0,n){ int a; cin>>a; if(i == 0) ans = abs(i+1 - a); else ans = __gcd(ans,abs(i+1 - a); if(a == i+1) ++cnt;} if(cnt == n) cout<<n-1<<'\n';else cout<<ans<<'\n'; return 0;}
^
./Main.cpp:2:23: error: ‘define’ does not name a type; did you mean ‘dysize’?
using namespace std; #define rep(i,a,n) for(int i=(a);i<(n);++i) #define int int64_t signed main(){ int n; cin>>n; int cnt = 0,ans; rep(i,0,n){ int a; cin>>a; if(i == 0) ans = abs(i+1 - a); else ans = __gcd(ans,abs(i+1 - a); if(a == i+1) ++cnt;} if(cnt == n) cout<<n-1<<'\n';else cout<<ans<<'\n'; return 0;}
^~~~~~
dysize
./Main.cpp:2:55: error: ‘i’ does not name a type
using namespace std; #define rep(i,a,n) for(int i=(a);i<(n);++i) #define int int64_t signed main(){ int n; cin>>n; int cnt = 0,ans; rep(i,0,n){ int a; cin>>a; if(i == 0) ans = abs(i+1 - a); else ans = __gcd(ans,abs(i+1 - a); if(a == i+1) ++cnt;} if(cnt == n) cout<<n-1<<'\n';else cout<<ans<<'\n'; return 0;}
^
./Main.cpp:2:61: error: expected unqualified-id before ‘++’ token
using namespace std; #define rep(i,a,n) for(int i=(a);i<(n);++i) #define int int64_t signed main(){ int n; cin>>n; int cnt = 0,ans; rep(i,0,n){ int a; cin>>a; if(i == 0) ans = abs(i+1 - a); else ans = __gcd(ans,abs(i+1 - a); if(a == i+1) ++cnt;} if(cnt == n) cout<<n-1<<'\n';else cout<<ans<<'\n'; return 0;}
^~
セット
テストケース