submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s346678665
p04045
C++
#include <bits/stdc++.h> #define repd(i,a,b) for (int i=(a);i<(b);i++) #define rep(i,n) repd(i,0,n) #define int long long typedef long long ll; using namespace std; const int MOD = 1000000007; const int INF = 1010000000; const double EPS = 1e-10; const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; signed main(){ int n,k;cin>>n>>k;bool d[10];rep(i,10)d[i] = false; rep(i,k){ int dd;cin>>dd; d[dd] = true; } repd(i,n,100000){ string s = to_string(i); vector<int> a; rep(j,s.length()){ a.push_back(s[j] - '0') } bool ok = true; rep(i,a.size()){ if(!d[a[i]]){ ok = false; continue; } } cout << i << endl; return 0; } }
a.cc: In function 'int main()': a.cc:22:30: error: expected ';' before '}' token 22 | a.push_back(s[j] - '0') | ^ | ; 23 | } | ~
s256600829
p04045
C++
#include<bits/stdc++.h> using namespace std; int d[10]= {0}; bool ok(int x) { int o; while(x) { o=x%10; if(d[o]) return false; x/=10; } return true; } int main() { int n,k,x; scanf("%d%d",&n,&k); for(int i=0; i<k; i++) { scanf("%d",&x); d[x]10000=1; } for(int i=n;; i++) { if(ok(i)) { printf("%d\n",i); break; } } return 0; }
a.cc: In function 'int main()': a.cc:23:13: error: expected ';' before numeric constant 23 | d[x]10000=1; | ^~~~~ | ;
s799611547
p04045
C++
#include <algorithm> #include <cstdio> #include <iostream> #include <map> #include <cmath> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #include <stdlib.h> #include <stdio.h> using namespace std; ll #define long long #define PI acos (- 1.0 ) #define FOR (I, A, B) for ( int I = (A); I <(B); ++ I) int main () { int N; int K; cin >> N >> K; bool D [ 10 ]; // if it is a bad number true (i, 0 , 10 ) D [i] = false ; FOR (i, 0 , K) { int d; cin >> d; D [d] = true ; } // Full search FOR (i, 0 , 10 * N) { if (N <= i) { int check = true ; string s = to_string (i); FOR (j, 0 , s.length ()) { if (D [s [j] - '0' ]) check = false ; } if (check) { cout << i << endl; return 0 ; } } } }
a.cc:16:4: error: stray '#' in program 16 | ll #define long long #define PI acos (- 1.0 ) #define FOR (I, A, B) for ( int I = (A); I <(B); ++ I) | ^ a.cc:16:31: error: stray '#' in program 16 | ll #define long long #define PI acos (- 1.0 ) #define FOR (I, A, B) for ( int I = (A); I <(B); ++ I) | ^ a.cc:16:56: error: stray '#' in program 16 | ll #define long long #define PI acos (- 1.0 ) #define FOR (I, A, B) for ( int I = (A); I <(B); ++ I) | ^ a.cc:16:1: error: 'll' does not name a type 16 | ll #define long long #define PI acos (- 1.0 ) #define FOR (I, A, B) for ( int I = (A); I <(B); ++ I) | ^~ a.cc:16:97: error: 'I' does not name a type 16 | ll #define long long #define PI acos (- 1.0 ) #define FOR (I, A, B) for ( int I = (A); I <(B); ++ I) | ^ a.cc:16:105: error: expected unqualified-id before '++' token 16 | ll #define long long #define PI acos (- 1.0 ) #define FOR (I, A, B) for ( int I = (A); I <(B); ++ I) | ^~
s622992504
p04045
C++
#include <iostream> #include <algorithm> #include <string > using namespace std; static int D[10]; bool check(int n){ int num=n; while(n){ if(D[n%10]==1) return true; n/=10; } cout<<num<<endl; return false; } int main() { int N,K; int num; cin>>N>>K; for(int i=1;i<=K;i++){ int num; cin>>num; D[num]=1; } num=N; while(check(num)){ num++; } }
a.cc:3:10: fatal error: string : No such file or directory 3 | #include <string > | ^~~~~~~~~~~~~~~~ compilation terminated.
s774927111
p04045
C++
#include<cstdio> #include<iostream> #include<cstring> using namespace std; int n,k,a; int s[7],s1[7]; int num[12]; int main() { scanf("%d%d",&n,&k); for(int i=1;i<=k;i++) { scanf("%d",&a); num[a]=1; } if(n==0) { for(int l=0;l<=9;l++) if(num[l]==0) { printf("%d",l); return 0; }0 } int len=0,n1=n; while(n>=1) { s[++len]=n%10; n/=10; } for(int i=len;i>0;i--) if(num[s[i]]==0) s1[i]=s[i]; else { for(int j=s[i]+1;j<=9;j++) if(num[j]==0) { s1[i]=j; for(int l=0;l<=9;l++) if(num[l]==0) { for(int m=i-1;m>0;m--) s1[m]=l; break; } break; } break; } for(int i=len;i>0;i--) printf("%d",s1[i]); }
a.cc: In function 'int main()': a.cc:23:27: error: expected ';' before '}' token 23 | }0 | ^ | ; 24 | } | ~
s558914670
p04045
C++
#include <bits/stdc++.h> using namespace std; map <int,int> m; int main() { int n,k,x; cin >> n >> k; for(int i=0;i<k;i++) { cin >> x; m[x]++; } while(true) { int temp = n; bool flag = true; while(temp) { if(m[temp%10] == 1) { flag = false; break; } temp /= 10; } if(flag) break; n++; } cour << n << endl; }
a.cc: In function 'int main()': a.cc:40:5: error: 'cour' was not declared in this scope 40 | cour << n << endl; | ^~~~
s503063678
p04045
C++
#include <bits/stdc++.h> using namespace std; map <int,int> m; int main() { int n,k; cin >> n >> k; for(int i=0;i<k;i++) { cin >> x; m[x]++; } while(true) { int temp = n; bool flag = true; while(temp) { if(m[temp%10] == 1) { flag = false; break; } temp /= 10; } if(flag) break; n++; } cour << n << endl; }
a.cc: In function 'int main()': a.cc:14:16: error: 'x' was not declared in this scope 14 | cin >> x; | ^ a.cc:40:5: error: 'cour' was not declared in this scope 40 | cour << n << endl; | ^~~~
s241283581
p04045
C++
def main(): N, K = map(int, input().split()) D = list(input().split()) i = 0 while True: S = str(N) f = True for s in S: if s in D: f = False break if f: break N += 1 print(N) if __name__ == "__main__": main()
a.cc:1:1: error: 'def' does not name a type 1 | def main(): | ^~~
s197066049
p04045
C++
#include <bits/stdc++.h> using namespace std; #define forx(i, a, b) for (int i = (a); i < (b); i++) #define rep(j, n) for (int j = 0; j < (n); j++) typedef long long ll; vector<bool>p(10); int judge(int n){ while(n!=0){ int b=n%10; rep(i,10){ if(b==a[i])return false; } n/=10; } return true; } int main() { ios::sync_with_stdio(false); cin.tie(0); int n,k; cin>>n>>k; rep(i,k){ int a; cin>>a; p[a]=true; } for(int i=n;;i++){ if(judge(i)){ cout<<i<<endl; break; } } return 0; }
a.cc: In function 'int judge(int)': a.cc:14:13: error: 'a' was not declared in this scope 14 | if(b==a[i])return false; | ^
s653163713
p04045
C++
#include <iostream> using namespace std; int main() { int N, K; cin >> N >> K; int D[10]; for (int i = 0; i < K; i++) { cin >> D[i]; } int n = N; while (1) { int a[5]; int nc = n; bool flag = true; for(int i = 0; i < 5; i++) { a[i] = nc % 10; nc -= a[i]; nc /= 10; } int J; if (a[4] == 0) { J = 4; if (a[3] == 0) { J = 3; if(a[2] == 0) { J = 2; if (a[1] == 0) { J = 1; } } } else J = 5; for (int i = 0; i < K; i++) { for (int j = 0; j < J; j++) { if (D[i] == a[j]) flag = false; } } if (flag) { cout << n << endl; break; } else { n++; } } return 0; }
a.cc: In function 'int main()': a.cc:51:2: error: expected '}' at end of input 51 | } | ^ a.cc:5:1: note: to match this '{' 5 | { | ^
s067401574
p04045
C++
#include<bits/stdc++.h> using namespace std; int main() { cin >> n >> k; for(int i = 0; i < k ; i++) { cin >> q; dislikes[q] = 1; } while(true) { int prev_n = n, cnt = 0; bool ok = false; s = toStr(n); for(int i = s.size() - 1; i >= 0; i--) { if(dislikes[s[i] - '0']) ok = true; } if(ok) n++; else break; } cout << n << endl; return 0; }
a.cc: In function 'int main()': a.cc:7:12: error: 'n' was not declared in this scope; did you mean 'yn'? 7 | cin >> n >> k; | ^ | yn a.cc:7:17: error: 'k' was not declared in this scope 7 | cin >> n >> k; | ^ a.cc:10:16: error: 'q' was not declared in this scope 10 | cin >> q; | ^ a.cc:11:9: error: 'dislikes' was not declared in this scope 11 | dislikes[q] = 1; | ^~~~~~~~ a.cc:18:9: error: 's' was not declared in this scope 18 | s = toStr(n); | ^ a.cc:18:13: error: 'toStr' was not declared in this scope 18 | s = toStr(n); | ^~~~~ a.cc:21:16: error: 'dislikes' was not declared in this scope 21 | if(dislikes[s[i] - '0']) | ^~~~~~~~
s792807231
p04045
C++
#include<iostream> using namespace std; int main(){ int N,K; int answer=0; cin>>N>>K; int D[K],R[5]={0}; for(int i=0;i<K;i++)cin>>D[i]; for(int ans=N;ans<=10*N;ans++){ bool flag=true; int ans_=ans; while(true){ int part=ans_%10;ans_/=10; for(int j=0;j<5;j++){if(part==D[j])flag=false;} if(ans_==0)break; } if(flag){answer=ans;break;} } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:19:9: error: 'ans' was not declared in this scope; did you mean 'abs'? 19 | cout<<ans<<endl; | ^~~ | abs
s351570218
p04045
C++
#include<iostream> using namespace std; int main(){ int N,K; cin>>N>>K; int D[K],R[5]={0}; for(int i=0;i<K;i++)cin>>D[i]; for(int ans=N;ans<=10*N;ans++){ bool flag=true; int ans_=ans; while(true){ int part=ans_%10;ans_/=10; for(int j=0;j<5;j++){if(part==D[j])flag=false;} if(ans_==0)break; } if(flag)break; } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:18:9: error: 'ans' was not declared in this scope; did you mean 'abs'? 18 | cout<<ans<<endl; | ^~~ | abs
s433308074
p04045
C++
#include<iostream> using namespace std; int main(){ int N,K; cin>>N>>K; int D[K],R[5]={0}; for(int i=0;i<K;i++)cin>>D[i]; for(int ans=N;ans<=10*N;ans++){ bool flag=true; int ans_=ans; while(true){ int part=ans_%10;ans_/=10; for(int j=0;j<5;j++){if(part==D[j])flag=false}; if(ans_==0)break; } if(flag)break; } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:13:52: error: expected ';' before '}' token 13 | for(int j=0;j<5;j++){if(part==D[j])flag=false}; | ^ | ; a.cc:18:9: error: 'ans' was not declared in this scope; did you mean 'abs'? 18 | cout<<ans<<endl; | ^~~ | abs
s845466601
p04045
C++
#include <iostream> using namespace std; int D[10]; inline bool ok(n) { while (n) { if (D[n%10]==0) { n/=10; } else { return false; } } return true; } int main() { cin.tie(0); std::ios::sync_with_stdio(false); int N,K; cin>>N>>K; for (int i=0; i<K; i++) { int d; cin>>d; D[d]=1; } while (!ok(N)) { N++; } cout<<N<<endl; return 0; }
a.cc:6:16: error: 'n' was not declared in this scope 6 | inline bool ok(n) { | ^ a.cc: In function 'int main()': a.cc:26:13: error: 'ok' cannot be used as a function 26 | while (!ok(N)) { | ~~^~~
s526758258
p04045
C++
#include<iostream> #include<algorithm> using namespace std; int main(){ int N,K; cin>>N>>K; int no[K]; for(int i=1;i<K;i++)cin>>no[K]; int digit[4]; int n=N; for(int i=0;i<4;i++){digit[i]=n%10;n/=10;} for(int i=0;i<4;i++){ for(j=0;j<K;j++){ if(digit[i]==no[j]&&digit[i]!=9)digit[i]++; if(digit[i]==no[j]&&digit[i]!=9){digit[i]=0;digit[i+1]++;} } } int ans=digit[0]+10*digit[1]+100*digit[2]*1000*digit[3]; cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:13:13: error: 'j' was not declared in this scope 13 | for(j=0;j<K;j++){ | ^
s631987962
p04045
C++
#include<iostream> #include<algorithm> using namespace std; int main(){ int N,K; cin>>N>>K; int no[K]; for(int i=1;i<K;i++)cin>>okies[K]; int digit[4]; int n=N; for(int i=0;i<4;i++){digit[i]=n%10;n/=10;} for(int i=0;i<4;i++){ for(j=0;j<K;j++){ if(digit[i]==no[j]&&digit[i]!=9)digit[i]++; if(digit[i]==no[j]&&digit[i]!=9){digit[i]=0;digit[i+1]++;} } } int ans=digit[0]+10*digit[1]+100*digit[2]*1000*digit[3]; cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:8:28: error: 'okies' was not declared in this scope 8 | for(int i=1;i<K;i++)cin>>okies[K]; | ^~~~~ a.cc:13:9: error: 'j' was not declared in this scope 13 | for(j=0;j<K;j++){ | ^
s436315072
p04045
C++
N = int(input()) num = list(map(int,input().split())) sumN = 0 for i in range(N): sumN += num[i] ave = sumN//N minN = 10**15 for j in range(-1,2): work = 0 for k in range(N): work += pow(ave+j-num[k],2) minN = min(minN,work) print(minN)
a.cc:1:1: error: 'N' does not name a type 1 | N = int(input()) | ^
s137781343
p04045
C++
#include<iostream> #include<algorithm> using namespace std; int main(){ int N,K; cin>>N>>K; int tar[5]; for(int i=0;i<5;i++){ tar[i]=N%10; N/=10; if(N==0)break; } int non[K]; for(int i=0;i<K;i++) cin>>non[K]; for(int i=0;i<5;i++){ for(int j=0;j<9-K;j++){ if(tar[i]==non[j])tar[i]++; } } int ans=tar[4]*10000+tar[3]*1000+tar[2]*100+tar[1]*10+tar[0]; cout<<ns<<endl; }
a.cc: In function 'int main()': a.cc:22:9: error: 'ns' was not declared in this scope; did you mean 'ans'? 22 | cout<<ns<<endl; | ^~ | ans
s238094744
p04045
Java
import java.io.*; import java.util.*; public class Beg42ProbC { static int MOD = 1000000007; static double EPS = 1e-9; public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(in.readLine()); String N = st.nextToken(); int length = N.length(); int K = Integer.parseInt(st.nextToken()); TreeSet<Integer> set = new TreeSet<Integer>(); st = new StringTokenizer(in.readLine()); for (int i = 0; i < K; i++) { set.add(Integer.parseInt(st.nextToken())); } int[] valid = new int[10 - K]; int index = 0; for (int i = 0; i < 10; i++) { if (!set.contains(i)) { valid[index] = i; index++; } } // System.out.println(Arrays.toString(valid)); int res = 0; boolean b = true; boolean large = false; for (int i = 0; i < length; i++) { int d = N.charAt(i) - '0'; // System.out.println(d); boolean done = false; if (large) { res = res * 10 + valid[0]; continue; } for (int j = 0; j < valid.length; j++) { if (valid[j] >= d) { if (i == 0 && valid[j] > d) large = true; res = res * 10 + valid[j]; done = true; break; } } if (!done) { b = false; break; } } if (!b) { res = valid[valid.length - 1]; for (int i = 0; i < length - 1; i++) { res = res * 10 + valid[0]; } } System.out.println(res); in.close(); } }
Main.java:4: error: class Beg42ProbC is public, should be declared in a file named Beg42ProbC.java public class Beg42ProbC { ^ 1 error
s475526508
p04045
C++
b
a.cc:1:1: error: 'b' does not name a type 1 | b | ^
s012513239
p04045
C++
#include <iostream> #include <string> #include <algorithm> using namespace std; int main() { int N, K; cin >> N >> K; vector<bool> ban(10, false); for(int i=0; i<K; ++i) { int b; cin >> b; ban[b] = true; } for(int i=N; ; ++i) { string s = to_string(i); bool ok = true; for(int j=0; j<s.size(); ++j) { if(ban[s[j] - '0']) { ok = false; break; } } if(ok) { cout << s << endl; break; } } }
a.cc: In function 'int main()': a.cc:9:5: error: 'vector' was not declared in this scope 9 | vector<bool> ban(10, false); | ^~~~~~ a.cc:4:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>' 3 | #include <algorithm> +++ |+#include <vector> 4 | using namespace std; a.cc:9:12: error: expected primary-expression before 'bool' 9 | vector<bool> ban(10, false); | ^~~~ a.cc:13:9: error: 'ban' was not declared in this scope 13 | ban[b] = true; | ^~~ a.cc:19:16: error: 'ban' was not declared in this scope 19 | if(ban[s[j] - '0']) { | ^~~
s575803758
p04045
C++
#include<stdio.h> int n;bool f[10]; bool ok(int x){ while(x){ if(f[x%10])return false; x/=10; } return true; } int main(){ int k,x; for(scanf("%d%d",&n,&k); k--;){ scanf("%d",&x); f[x] = true; } while(!ok(n))n++; printf("%d\n",n); return 0;
a.cc: In function 'int main()': a.cc:18:18: error: expected '}' at end of input 18 | return 0; | ^ a.cc:10:11: note: to match this '{' 10 | int main(){ | ^
s241771729
p04045
C++
//#include <bits/stdc++.h> #include <vector> #include <list> #include <queue> #include <deque> #include <map> #include <stack> #include <bitset> #include <array> #include <set> #include <string> #include <iterator> #include <algorithm> #include <numeric> #include <ios> #include <sstream> #include <iostream> #include <fstream> #include <climits> using namespace std; using ll=long long; using vi=vector<int>; using vvi=vector<vi>; using vs=vector<string>; using pii=pair<int,int>; using pll=pair<ll,ll>; void OUT(bool isTrue, string t="YES", string f="NO"){ cout<<(isTrue?t:f)<<endl; } void out(bool isTrue, string t="yes", string f="yes"){ cout<<(isTrue?t:f)<<endl; } template <typename T> string printItr(T b, T e, string delim=" ") { stringstream ss; ostream_iterator<decltype(*b)> out_it(ss, delim.c_str()); copy(b,e - 1, out_it); ss<<*(e-1); return ss.str(); } void bulk(){} template <class Head, class... Tail> void bulk(Head& head, Tail&... tail){ cin>>head; bulk(tail...); } #define rep(i,n) for(int i=0;i<n;i++) #define rrep(i,n) for(int i=n-1;i>=0;i--) #define range(i,m,n) for(int i=m; i<n;i++) #define each(i,n) for(auto i:n) #define all(i) i.begin(),i.end() #define cint(...) int __VA_ARGS__;bulk(__VA_ARGS__); int main(void){ cint(n,k); vi a(k),b; rep(i,k){cin>>a[i];} rep(i,10){if(find(all(a),i)==a.end())b.push_back(i);} b.push_back(b[0]+10); rep(i,(int)log10(n)+1){ int p=n/((int)pow(10,i))%10; n+=(*lower_bound(all(b),p)-p)*(int)pow(10,i); } cout<<n; }
a.cc: In function 'int main()': a.cc:71:16: error: 'log10' was not declared in this scope 71 | rep(i,(int)log10(n)+1){ | ^~~~~ a.cc:58:32: note: in definition of macro 'rep' 58 | #define rep(i,n) for(int i=0;i<n;i++) | ^ a.cc:72:23: error: 'pow' was not declared in this scope 72 | int p=n/((int)pow(10,i))%10; | ^~~
s111959552
p04045
C++
However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.
a.cc:1:1: error: 'However' does not name a type 1 | However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money. | ^~~~~~~
s203920150
p04045
C++
#include <iostream> #include <algorithm> #include <string.h> using namespace sdtd; int i,j,k,n; bool dislike[10]; bool cek(int x) { while (x>0) { int buntut=x%10; if (dislike[buntut]) return false; x/=10; } return true; } int main() { memset(dislike,0,sizeof(dislike)); cin>>n>>k; for (i=1;i<=k;i++) { cin>>j; dislike[j]=1; } while (1) { if (cek(n)) { cout<<n<<"\n"; return 0; } n++; } }
a.cc:4:17: error: 'sdtd' is not a namespace-name 4 | using namespace sdtd; | ^~~~ a.cc: In function 'int main()': a.cc:23:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 23 | cin>>n>>k; | ^~~ | std::cin In file included from a.cc:1: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:33:25: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 33 | cout<<n<<"\n"; | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~
s600899493
p04045
C++
#include <iostream> #include <algorithm> #include <string.h> int i,j,k,n; bool dislike[10]; bool cek(int x) { while (x>0) { int buntut=x%10; if (dislike[buntut]) return false; x/=10; } return true; } int main() { memset(dislike,0,sizeof(dislike)); cin>>n>>k; for (i=1;i<=k;i++) { cin>>j; dislike[j]=1; } while (1) { if (cek(n)) { cout<<n<<"\n"; return 0; } n++; } }
a.cc: In function 'int main()': a.cc:23:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 23 | cin>>n>>k; | ^~~ | std::cin In file included from a.cc:1: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:33:25: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 33 | cout<<n<<"\n"; | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~
s317818320
p04045
C++
import java.util.*; // ABC 42-C // http://abc042.contest.atcoder.jp/tasks/arc058_a public class Main { public static void main (String[] args) throws java.lang.Exception { Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); HashMap<Integer, Integer> avoid = new HashMap<Integer, Integer>(); for (int i = 0; i < k; i++) { avoid.put(in.nextInt(), 1); } while (!isConditionMet(avoid, n)) { n++; } System.out.println(n); } public static boolean isConditionMet(HashMap<Integer, Integer> avoid, int n) { while (n > 0) { if (avoid.containsKey(n % 10)) { return false; } if (n == 0) { break; } n /= 10; } return true; } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.util.*; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:6:1: error: expected unqualified-id before 'public' 6 | public class Main { | ^~~~~~
s500324501
p04045
Java
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int K = sc.nextInt(); ArrayList<Integer> dislike = new ArrayList<Integer>(); for(int i = 0; i < K; i++) { dislike.add(sc.nextInt()); } int ans = N; while(true) { String s = String.valueOf(ans); int count = 0; for(int i = 0; i < s.length(); i++) { int d = Integer.parseInt(s.charAt(i)); if(dislike.contains(d)) count++; } if(count == 0) break; } System.out.println(ans); } }
Main.java:17: error: incompatible types: char cannot be converted to String int d = Integer.parseInt(s.charAt(i)); ^ Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output 1 error
s428478667
p04045
Java
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int K = sc.nextInt(); ArrayList<Integer> dislike = new ArrayList<Integer>(); for(int i = 0; i < K; i++) { dislike.add(sc.nextInt()); } ArrayList<Integer> like = new ArrayList<Integer>(); for(int i = 0; i < 10; i++) { if(!(dislike.contains(i))) like.add(i); } ArrayList<Integer> digit = new ArrayList<Integer>(); int digitNum = 0; for(int i = 1; i <= 4; i++) { if(N < (int)Math.pow(10, i)) { digitNum = i; break; } } for(int i = 0; i < digitNum; i++) { int a = N / (int)Math.pow(10, digitNum - i - 1); digit.get(a % 10); } int firstIndex = 4; for(int i = 0; i < digit.size(); i++) { if(digit.get(i) > like.get(like.size() - 1)) { firstIndex = i; break; } } String ans = ""; if(firstIndex == 4) { for(int i = 0; i < digit.size(); i++) { for(int j = 0; j < like.size(); j++) { if(digit.get(i) <= like.get(j)) { ans += String.valueOf(like.get(j)); break; } } } } else { int min = like.get(0); int nonzero = min; if(min == 0) nonzero = like.get(1); boolean flg = false; int victory = 0; for(int i = 0; i < firstIndex; i++) { if(digit.get(i) < like.get(like.size() - 1)) { victory = i; flg = true; break; } } if(flg) { for(int i = 0; i < victory; i++) { for(int j = 0; j < like.size(); j++) { if(digit.get(i) <= like.get(j)) { ans += String.valueOf(like.get(j)); break; } } } for(int j = 0; j < like.size(); j++) { if(digit.get(i) < like.get(j)) { ans += String.valueOf(like.get(j)); break; } } for(int i = victory + 1; i < digit.size(); i++) { ans += String.valueOf(min); } } else { ans += String.valueOf(nonzero); for(int i = 0; i < digit.size(); i++) { ans += String.valueOf(min); } } } System.out.println(Integer.parseInt(ans)); } }
Main.java:68: error: cannot find symbol if(digit.get(i) < like.get(j)) { ^ symbol: variable i location: class Main 1 error
s412927946
p04045
C++
#include <stdio.h> #include <cstdlib> #include <algorithm> int N, K, D[11]; char temp[112345]; bool match_flag = false; int ans; int GetDigit(int num) { int res = 0; while (num != 0) { num /= 10; ++res; } return res; } int main(void) { scanf("%d%d", &N, &K); for (int i = 0; i < K; ++i) { scanf("%d", &D[i]); } for (int i = N; i <= 10 * N; ++i) { itoa(i, temp, 10); for (int j = 0; j < GetDigit(i); ++j) { for (int k = 0; k < K; ++k) { if ((temp[j] - '0') == D[k]) { match_flag = true; break; } } if (match_flag == true) { break; } } if (match_flag == false) { ans = i; break; } match_flag = false; } printf("%d\n", ans); return 0; }
a.cc: In function 'int main()': a.cc:28:17: error: 'itoa' was not declared in this scope 28 | itoa(i, temp, 10); | ^~~~
s945846183
p04045
C++
#include <stdio.h> #include <stdlib.h> #include <algorithm> int N, K, D[11]; char temp[112345]; bool match_flag = false; int ans; int GetDigit(int num) { int res = 0; while (num != 0) { num /= 10; ++res; } return res; } int main(void) { scanf("%d%d", &N, &K); for (int i = 0; i < K; ++i) { scanf("%d", &D[i]); } for (int i = N; i <= 10 * N; ++i) { itoa(i, temp, 10); for (int j = 0; j < GetDigit(i); ++j) { for (int k = 0; k < K; ++k) { if ((temp[j] - '0') == D[k]) { match_flag = true; break; } } if (match_flag == true) { break; } } if (match_flag == false) { ans = i; break; } match_flag = false; } printf("%d\n", ans); return 0; }
a.cc: In function 'int main()': a.cc:28:17: error: 'itoa' was not declared in this scope 28 | itoa(i, temp, 10); | ^~~~
s856066194
p04045
C++
#include <stdio.h> #include <algorithm> int N, K, D[11]; char temp[112345]; bool match_flag = false; int ans; int GetDigit(int num) { int res = 0; while (num != 0) { num /= 10; ++res; } return res; } int main(void) { scanf("%d%d", &N, &K); for (int i = 0; i < K; ++i) { scanf("%d", &D[i]); } for (int i = N; i <= 10 * N; ++i) { itoa(i, temp, 10); for (int j = 0; j < GetDigit(i); ++j) { for (int k = 0; k < K; ++k) { if ((temp[j] - '0') == D[k]) { match_flag = true; break; } } if (match_flag == true) { break; } } if (match_flag == false) { ans = i; break; } match_flag = false; } printf("%d\n", ans); return 0; }
a.cc: In function 'int main()': a.cc:27:17: error: 'itoa' was not declared in this scope 27 | itoa(i, temp, 10); | ^~~~
s850504028
p04045
C++
#include <stdio.h> #include <algorithm> int N, K, D[11]; char temp[112345]; bool match_flag = false; int ans; int GetDigit(int num) { int res = 0; while (num != 0) { num /= 10; ++res; } return res; } int main(void) { scanf("%d%d", &N, &K); for (int i = 0; i < K; ++i) { scanf("%d", &D[i]); } for (int i = N; i <= 10 * N; ++i) { itoa(i, temp, 10); for (int j = 0; j < GetDigit(i); ++j) { for (int k = 0; k < K; ++k) { if ((temp[j] - '0') == D[k]) { match_flag = true; break; } } if (match_flag == true) { break; } } if (match_flag == false) { ans = i; break; } match_flag = false; } printf("%d\n", ans); return 0; }
a.cc: In function 'int main()': a.cc:27:17: error: 'itoa' was not declared in this scope 27 | itoa(i, temp, 10); | ^~~~
s006235748
p04045
C++
#include<iostream> #include<vector> #include<string> using namespace std; int Upper_Num(int num, vector<int> n_d){ for (int i = 0; i < n_d.size(); ++i){ if (n_d[i] > num)return n_d[i]; } return -1; } int main(){ string N; int K; cin >> N >> K; vector<int> D(K); for (int i = 0; i < K; ++i){ cin >> D[i]; } vector<int> N_D; for (int i = 0; i < 10; ++i){ if (find(D.begin(), D.end(), i) == D.end()){ N_D.push_back(i); } } int max_index = -1; for (int i = 0; i < N.size(); ++i){ if (find(D.begin(), D.end(), N[i] - '0') != D.end()){ max_index = i; } } if (max_index == -1){ cout << N << endl; return 0; } while (true){ if (max_index + 1 > N.size()){ for (int i = 0; i < N.size(); ++i){ if (N_D[0]==0)N[i] = '0'; else N[i] = '0' + N_D[1]; } cout << N_D[1] << N << endl; return 0; } if (Upper_Num(N[max_index] - '0', N_D) != -1){ N[max_index] = Upper_Num(N[max_index] - '0', N_D) + '0'; for (int i = max_index - 1; i >= 0; --i){ N[i] = N_D[0] + '0'; } break; } else{ ++max_index; } } cout << N << endl; return 0; }
a.cc: In function 'int main()': a.cc:24:25: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int&)' 24 | if (find(D.begin(), D.end(), i) == D.end()){ | ~~~~^~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/bits/locale_facets.h:48, from /usr/include/c++/14/bits/basic_ios.h:37, from /usr/include/c++/14/ios:46, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)' 435 | find(istreambuf_iterator<_CharT> __first, | ^~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed: a.cc:24:25: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>' 24 | if (find(D.begin(), D.end(), i) == D.end()){ | ~~~~^~~~~~~~~~~~~~~~~~~~~~~ a.cc:31:25: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int)' 31 | if (find(D.begin(), D.end(), N[i] - '0') != D.end()){ | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)' 435 | find(istreambuf_iterator<_CharT> __first, | ^~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed: a.cc:31:25: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>' 31 | if (find(D.begin(), D.end(), N[i] - '0') != D.end()){ | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s256751269
p04045
C++
#include <stdio.h> #include <algorithm> int N, K, D[11]; char buf[7]; bool break_flag = false; int ans; int my_atoi(char c) { switch (c) { case '1': return 1; case '2': return 2; case '3': return 3; case '4': return 4; case '5': return 5; case '6': return 6; case '7': return 7; case '8': return 8; case '9': return 9; } } int main(void) { scanf("%d%d", &N, &K); for (int i = 0; i < K; ++i) { scanf("%d", &D[i]); } for (int i = N; i <= 10 * N; ++i) { sprintf(buf, "%d", i); for (int j = 0; j < strlen(buf); ++j) { for (int k = 0; k < K; ++k) { if (my_atoi(buf[j]) == D[k]) { break_flag = true; break; } } if (break_flag == true) { break; } } if (break_flag == false) { ans = i; break; } break_flag = false; } printf("%d\n", ans); return 0; }
a.cc: In function 'int main()': a.cc:42:37: error: 'strlen' was not declared in this scope 42 | for (int j = 0; j < strlen(buf); ++j) | ^~~~~~ a.cc:3:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include <algorithm> +++ |+#include <cstring> 3 | a.cc: In function 'int my_atoi(char)': a.cc:32:1: warning: control reaches end of non-void function [-Wreturn-type] 32 | } | ^
s641053508
p04045
C++
#include <stdio.h> #include <algorithm> int N, K, D[11]; char buf[7]; int ans; int my_atoi(char c) { switch (c) { case '1': return 1; case '2': return 2; case '3': return 3; case '4': return 4; case '5': return 5; case '6': return 6; case '7': return 7; case '8': return 8; case '9': return 9; } } int main(void) { scanf("%d%d", &N, &K); for (int i = 0; i < K; ++i) { scanf("%d", &D[i]); } for (int i = N; i <= 10 * N; ++i) { sprintf(buf, "%d", i); for (int j = 0; j < strlen(buf); ++j) { for (int k = 0; k < K; ++k) { if (my_atoi(buf[j]) == D[k]) { goto not; } } } ans = i; break; not: i = i; } printf("%d\n", ans); return 0; }
a.cc: In function 'int main()': a.cc:41:37: error: 'strlen' was not declared in this scope 41 | for (int j = 0; j < strlen(buf); ++j) | ^~~~~~ a.cc:3:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include <algorithm> +++ |+#include <cstring> 3 | a.cc:47:46: error: expected identifier before 'not' token 47 | goto not; | ^~~ a.cc:47:45: error: expected ';' before 'not' token 47 | goto not; | ^~~~ | ; a.cc:47:49: error: expected primary-expression before ';' token 47 | goto not; | ^ a.cc:53:20: error: expected primary-expression before ':' token 53 | not: | ^ a.cc: In function 'int my_atoi(char)': a.cc:31:1: warning: control reaches end of non-void function [-Wreturn-type] 31 | } | ^
s808590691
p04045
C++
#include <stdio.h> #include <algorithm> int N, K, D[11]; char buf[7]; int ans; int my_atoi(char c) { switch (c) { case '1': return 1; case '2': return 2; case '3': return 3; case '4': return 4; case '5': return 5; case '6': return 6; case '7': return 7; case '8': return 8; case '9': return 9; } } int main(void) { scanf("%d%d", &N, &K); for (int i = 0; i < K; ++i) { scanf("%d", &D[i]); } for (int i = N; i <= 10 * N; ++i) { itoa(i, buf, 10); for (int j = 0; j < strlen(buf); ++j) { for (int k = 0; k < K; ++k) { if (my_atoi(buf[j]) == D[k]) { goto not; } } } ans = i; break; not: i = i; } printf("%d\n", ans); return 0; }
a.cc: In function 'int main()': a.cc:40:17: error: 'itoa' was not declared in this scope 40 | itoa(i, buf, 10); | ^~~~ a.cc:41:37: error: 'strlen' was not declared in this scope 41 | for (int j = 0; j < strlen(buf); ++j) | ^~~~~~ a.cc:3:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include <algorithm> +++ |+#include <cstring> 3 | a.cc:47:46: error: expected identifier before 'not' token 47 | goto not; | ^~~ a.cc:47:45: error: expected ';' before 'not' token 47 | goto not; | ^~~~ | ; a.cc:47:49: error: expected primary-expression before ';' token 47 | goto not; | ^ a.cc:53:20: error: expected primary-expression before ':' token 53 | not: | ^ a.cc: In function 'int my_atoi(char)': a.cc:31:1: warning: control reaches end of non-void function [-Wreturn-type] 31 | } | ^
s122353313
p04045
Java
import java.util.Scanner; import java.util.LinkedList; public class ABC042C { public static void main(String[] args) { IrohasObsession iroha = new IrohasObsession(); iroha.run(); } } class IrohasObsession { int N; int K; int[] dislikeNums; IrohasObsession() { //input Scanner cin = new Scanner(System.in); this.N = cin.nextInt(); this.K = cin.nextInt(); this.dislikeNums = new int[K]; for (int i = 0; i < K; i++) { dislikeNums[i] = cin.nextInt(); } } void run() { int i = N; while (true) { if (!isContains(i)) { break; } i++; } System.out.println(i); } boolean isContains(int num) { char[] tmpNums = String.valueOf(num).toCharArray(); LinkedList<Integer> list = new LinkedList<Integer>(); for (int i = 0; i < tmpNums.length; i++) { list.add(Integer.valueOf(String.valueOf(tmpNums[i]))); } for (int i = 0; i < K; i++) { if (list.contains(this.dislikeNums[i])) { return true; } } return false; } }
Main.java:4: error: class ABC042C is public, should be declared in a file named ABC042C.java public class ABC042C { ^ 1 error
s905841141
p04045
C++
#include <iostream> #include <string> using namespace std; int main() { // 入力 int N, K; // N:購入金額, K:嫌いな数字の個数 cin >> N >> K; bool num[10] = {false}; int tmp; for (int i=0; i<K; i++) { cin >> tmp; num[tmp] = true; } bool able[10000] = {false}; string n; for (int i=1; i<=10000; i++) { n=to_string(i); for (int j=0; j<n.size(); j++) { tmp = (int)(n[j]-'0'); if (num[tmp]) able[i] = true; } } for (int i=N; i<=10000; i++) { if (!able[i]) { int ans = i; } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:32:11: error: 'ans' was not declared in this scope; did you mean 'abs'? 32 | cout << ans << endl; | ^~~ | abs
s024442889
p04045
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Arrays; public class Main { private static Scanner sc; public static void main(String[] args) { Main instance = new Main(); instance.solve(); } private void solve() { try { boolean[] numbers = new boolean[10]; int n = sc.nextInt(); int k = sc.nextInt(); for (int i = 0; i < 10; i++) { numbers[i] = true; } for (int i = 0; i < k; i++) { int d = sc.nextInt(); numbers[d] = false; } while (true) { boolean isValid = true; String number = String.valueOf(n); for (int j = 0; j < number.length(); j++) { int index = Integer.parseInt(number.charAt(0)); if (numbers[index] == false) { isValid = false; break; } } if (isValid) { break; } n++; } System.out.println(n); } catch (Exception e) { e.printStackTrace(); } } private class Scanner { String[] s; int i; BufferedReader br; String regex = " "; public Scanner() { s = new String[0]; i = 0; br = new BufferedReader(new InputStreamReader(System.in)); } @Override protected void finalize() throws Throwable { try { super.finalize(); } finally { destruction(); } } private void destruction() throws IOException { if (br != null) br.close(); } public String next() throws IOException { if (i < s.length) return s[i++]; String st = br.readLine(); while (st == "") st = br.readLine(); s = st.split(regex, 0); i = 0; return s[i++]; } public int nextInt() throws NumberFormatException, IOException { return Integer.parseInt(next()); } public Long nextLong() throws NumberFormatException, IOException { return Long.parseLong(next()); } public Double nextDouble() throws NumberFormatException, IOException { return Double.parseDouble(next()); } } }
Main.java:39: error: incompatible types: char cannot be converted to String int index = Integer.parseInt(number.charAt(0)); ^ Main.java:71: warning: [removal] finalize() in Object has been deprecated and marked for removal protected void finalize() throws Throwable { ^ Main.java:73: warning: [removal] finalize() in Object has been deprecated and marked for removal super.finalize(); ^ Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output 1 error 2 warnings
s652490176
p04045
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Arrays; public class Main { private static Scanner sc; public static void main(String[] args) { Main instance = new Main(); instance.solve(); } private void solve() { try { boolean[] numbers = new boolean[10]; int n = sc.nextInt(); int k = sc.nextInt(); for (int i = 0; i < 10; i++) { numbers[i] = true; } for (int i = 0; i < k; i++) { int d = sc.nextInt(); numbers[d] = false; } while (true) { boolean isValid = true; for (int j = 0; j < n.length(); j++) { String number = String.valueOf(n.charAt(j)); if (numbers[Integer.parseInt(number)] == false) { isValid = false; break; } } if (isValid) { break; } n++; } System.out.println(n); } catch (Exception e) { e.printStackTrace(); } } private class Scanner { String[] s; int i; BufferedReader br; String regex = " "; public Scanner() { s = new String[0]; i = 0; br = new BufferedReader(new InputStreamReader(System.in)); } @Override protected void finalize() throws Throwable { try { super.finalize(); } finally { destruction(); } } private void destruction() throws IOException { if (br != null) br.close(); } public String next() throws IOException { if (i < s.length) return s[i++]; String st = br.readLine(); while (st == "") st = br.readLine(); s = st.split(regex, 0); i = 0; return s[i++]; } public int nextInt() throws NumberFormatException, IOException { return Integer.parseInt(next()); } public Long nextLong() throws NumberFormatException, IOException { return Long.parseLong(next()); } public Double nextDouble() throws NumberFormatException, IOException { return Double.parseDouble(next()); } } }
Main.java:36: error: int cannot be dereferenced for (int j = 0; j < n.length(); j++) { ^ Main.java:37: error: int cannot be dereferenced String number = String.valueOf(n.charAt(j)); ^ Main.java:69: warning: [removal] finalize() in Object has been deprecated and marked for removal protected void finalize() throws Throwable { ^ Main.java:71: warning: [removal] finalize() in Object has been deprecated and marked for removal super.finalize(); ^ 2 errors 2 warnings
s529112607
p04045
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Arrays; public class Main { private static Scanner sc; public static void main(String[] args) { Main instance = new Main(); instance.solve(); } private void solve() { try { boolean[] numbers = new boolean[10]; int n = sc.nextInt(); int k = sc.nextInt(); for (int i = 0; i < 10; i++) { numbers[i] = true; } for (int i = 0; i < k; i++) { int d = sc.nextInt(); numbers[d] = false; } while (true) { String number = String.valueOf(n.charAt(i)); boolean isValid = true; for (int j = 0; j < n.length(); j++) { if (numbers[Integer.parseInt(number)] == false) { isValid = false; break; } } if (isValid) { break; } n++; } System.out.println(n); } catch (Exception e) { e.printStackTrace(); } } private class Scanner { String[] s; int i; BufferedReader br; String regex = " "; public Scanner() { s = new String[0]; i = 0; br = new BufferedReader(new InputStreamReader(System.in)); } @Override protected void finalize() throws Throwable { try { super.finalize(); } finally { destruction(); } } private void destruction() throws IOException { if (br != null) br.close(); } public String next() throws IOException { if (i < s.length) return s[i++]; String st = br.readLine(); while (st == "") st = br.readLine(); s = st.split(regex, 0); i = 0; return s[i++]; } public int nextInt() throws NumberFormatException, IOException { return Integer.parseInt(next()); } public Long nextLong() throws NumberFormatException, IOException { return Long.parseLong(next()); } public Double nextDouble() throws NumberFormatException, IOException { return Double.parseDouble(next()); } } }
Main.java:34: error: cannot find symbol String number = String.valueOf(n.charAt(i)); ^ symbol: variable i location: class Main Main.java:34: error: int cannot be dereferenced String number = String.valueOf(n.charAt(i)); ^ Main.java:36: error: int cannot be dereferenced for (int j = 0; j < n.length(); j++) { ^ Main.java:68: warning: [removal] finalize() in Object has been deprecated and marked for removal protected void finalize() throws Throwable { ^ Main.java:70: warning: [removal] finalize() in Object has been deprecated and marked for removal super.finalize(); ^ 3 errors 2 warnings
s405095402
p04045
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Arrays; public class Main { private static Scanner sc; public static void main(String[] args) { Main instance = new Main(); sc = instance.new Scanner(); instance.solve(); } private void solve() { try { List<Integer> numbers = new ArrayList<Integer>(Arrays.asList(0,1,2,3,4,5,6,7,8,9)); String n = sc.next(); int k = sc.nextInt(); for (int i = 0; i < k; i++) { int d = sc.nextInt(); for (int j = 0; j < 10; j++) { if (numbers.get(j) == d) { numbers.remove(j); break; } } } String[] answerArray = new String[4]; for (int i = 0; i < n.length(); i++) { int number = n.charAt(i); for (int j = 0; j < numbers.length(); j++) { if (number <= numbers.get(j)) { answerArray[i] = String.valueOf(numbers.get(j)); break; } } } System.out.println(Integer.parseInt(String.join("", answerArray))); } catch (Exception e) { e.printStackTrace(); } } private class Scanner { String[] s; int i; BufferedReader br; String regex = " "; public Scanner() { s = new String[0]; i = 0; br = new BufferedReader(new InputStreamReader(System.in)); } @Override protected void finalize() throws Throwable { try { super.finalize(); } finally { destruction(); } } private void destruction() throws IOException { if (br != null) br.close(); } public String next() throws IOException { if (i < s.length) return s[i++]; String st = br.readLine(); while (st == "") st = br.readLine(); s = st.split(regex, 0); i = 0; return s[i++]; } public int nextInt() throws NumberFormatException, IOException { return Integer.parseInt(next()); } public Long nextLong() throws NumberFormatException, IOException { return Long.parseLong(next()); } public Double nextDouble() throws NumberFormatException, IOException { return Double.parseDouble(next()); } } }
Main.java:40: error: cannot find symbol for (int j = 0; j < numbers.length(); j++) { ^ symbol: method length() location: variable numbers of type List<Integer> Main.java:68: warning: [removal] finalize() in Object has been deprecated and marked for removal protected void finalize() throws Throwable { ^ Main.java:70: warning: [removal] finalize() in Object has been deprecated and marked for removal super.finalize(); ^ 1 error 2 warnings
s191410134
p04045
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Arrays; public class Main { private static Scanner sc; public static void main(String[] args) { Main instance = new Main(); sc = instance.new Scanner(); instance.solve(); } private void solve() { try { List<Integer> numbers = new ArrayList<Integer>(Arrays.asList(0,1,2,3,4,5,6,7,8,9)); String n = sc.next(); int k = sc.nextInt(); for (int i = 0; i < k; i++) { int d = sc.nextInt(); if (numbers(i) == d) { numbers.remove(i); continue; } } String[] answerArray = new String[4]; for (int i = 0; i < n.length(); i++) { int number = n.charAt(i); for (int j = 0; j < k; j++) { if (number <= numbers.get(j)) { answerArray[i] = String.valueOf(numbers.get(j)); break; } } } System.out.println(Intger.parseInt(String.join("", answerArray))); } catch (Exception e) { e.printStackTrace(); } } private class Scanner { String[] s; int i; BufferedReader br; String regex = " "; public Scanner() { s = new String[0]; i = 0; br = new BufferedReader(new InputStreamReader(System.in)); } @Override protected void finalize() throws Throwable { try { super.finalize(); } finally { destruction(); } } private void destruction() throws IOException { if (br != null) br.close(); } public String next() throws IOException { if (i < s.length) return s[i++]; String st = br.readLine(); while (st == "") st = br.readLine(); s = st.split(regex, 0); i = 0; return s[i++]; } public int nextInt() throws NumberFormatException, IOException { return Integer.parseInt(next()); } public Long nextLong() throws NumberFormatException, IOException { return Long.parseLong(next()); } public Double nextDouble() throws NumberFormatException, IOException { return Double.parseDouble(next()); } } }
Main.java:28: error: cannot find symbol if (numbers(i) == d) { ^ symbol: method numbers(int) location: class Main Main.java:46: error: cannot find symbol System.out.println(Intger.parseInt(String.join("", answerArray))); ^ symbol: variable Intger location: class Main Main.java:66: warning: [removal] finalize() in Object has been deprecated and marked for removal protected void finalize() throws Throwable { ^ Main.java:68: warning: [removal] finalize() in Object has been deprecated and marked for removal super.finalize(); ^ 2 errors 2 warnings
s059335603
p04045
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Arrays; public class Main { private static Scanner sc; public static void main(String[] args) { Main instance = new Main(); sc = instance.new Scanner(); instance.solve(); } private void solve() { try { List<Integer> numbers = new ArrayList<Integer>(Arrays.asList(0,1,2,3,4,5,6,7,8,9)); String n = sc.next(); int k = sc.nextInt(); for (int i = 0; i < k; i++) { int d = sc.nextInt(); if (numbers(i) == d) { numbers.remove(i); continue; } } String[] answerArray = new String[4]; for (int i = 0; i < n.length(); i++) { int number = n.charAt(i); for (int j = 0; j < k; j++) { if (number <= numbers.get(j)) { answerArray[i] = String.valueOf(numbers.get(j)); break; } } } System.out.println(Intger.parseInt(String.join("", answerArray)); } catch (Exception e) { e.printStackTrace(); } } private class Scanner { String[] s; int i; BufferedReader br; String regex = " "; public Scanner() { s = new String[0]; i = 0; br = new BufferedReader(new InputStreamReader(System.in)); } @Override protected void finalize() throws Throwable { try { super.finalize(); } finally { destruction(); } } private void destruction() throws IOException { if (br != null) br.close(); } public String next() throws IOException { if (i < s.length) return s[i++]; String st = br.readLine(); while (st == "") st = br.readLine(); s = st.split(regex, 0); i = 0; return s[i++]; } public int nextInt() throws NumberFormatException, IOException { return Integer.parseInt(next()); } public Long nextLong() throws NumberFormatException, IOException { return Long.parseLong(next()); } public Double nextDouble() throws NumberFormatException, IOException { return Double.parseDouble(next()); } } }
Main.java:46: error: ')' or ',' expected System.out.println(Intger.parseInt(String.join("", answerArray)); ^ 1 error
s220608385
p04045
C
#include <iostream> #include <vector> int main(void) { int n; int k; std::cin >> n >> k; auto ds = std::vector<int>(k); for (int i = 0; i < k; i++) { std::cin >> ds[i]; } int result = n; while (true) { auto s = std::to_string(result); for (auto &&c : s) { for (auto &&d : ds) { if (d == c - '0') { goto next; } } } std::cout << result << '\n'; return 0; next: result += n; } }
main.c:1:10: fatal error: iostream: No such file or directory 1 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s924842974
p04045
Java
import java.util.Scanner; public class irohaDigit { public static void main(String[] args) { int N; int D; Scanner sc = new Scanner(System.in); N = sc.nextInt(); D = sc.nextInt(); int d[] = new int[10]; for(int i=0;i<D;i++) { d[sc.nextInt()]=1; } int sum=0; int start9= 0; int maxD = String.valueOf(N).length(); for(int i=maxD-1;i>=0;i--) { int x = N/(int)(Math.pow(10,i)); N = N%(int)Math.pow(10, i); if(d[x]==1) { { for(int j=x;j<10;j++) { if(d[j]!=1) { x=j; break; } else if(j==9) { j=-1; start9=1; } } } } if(i==(maxD-1) && start9==1) sum = sum+10*(int)Math.pow(10,i); else sum = sum+x*(int)Math.pow(10,i); if(N==0) break; } System.out.print(sum); } }
Main.java:2: error: class irohaDigit is public, should be declared in a file named irohaDigit.java public class irohaDigit { ^ 1 error
s163252875
p04045
Java
import java.util.Scanner; import java.util.Arrays; public class irohaDigit { public static void main(String[] args) { int N; int D; Scanner sc = new Scanner(System.in); N = sc.nextInt(); D = sc.nextInt(); int d[] = new int[10]; for(int i=0;i<D;i++) { d[sc.nextInt()]=1; } int sum=0; int start9= 0; int maxD = String.valueOf(N).length(); for(int i=maxD-1;i>=0;i--) { int x = N/(int)(Math.pow(10,i)); N = N%(int)Math.pow(10, i); if(d[x]==1) { { for(int j=x;j<10;j++) { if(d[j]!=1) { x=j; break; } else if(j==9) { j=-1; start9=1; } } } } if(i==(maxD-1) && start9==1) sum = sum+10*(int)Math.pow(10,i); else sum = sum+x*(int)Math.pow(10,i); if(N==0) break; } System.out.print(sum); } }
Main.java:3: error: class irohaDigit is public, should be declared in a file named irohaDigit.java public class irohaDigit { ^ 1 error
s936850011
p04045
C++
#include <iostream> #include <cmath> #include <algorithm> #include <stdio.h> #include <string> #include <string.h> #include <stdlib.h> #include <sstream> #include <vector> #include <map> using namespace std; const int N = 10000; int arr[N]; bool func(string str, int *arr, int k); int main() { string str; int n, k; cin >> n >> k; for (int i = 0; i < k; i++) { cin >> arr[i]; } str = to_string(n); while(func(str, arr, k)){ n++; str = to_string(n); } cout << str << endl; return 0; } bool func(string str, int *arr, int k) { for (int i = 0; i < k; i++) { if (str.find(to_string(arr[i])) != -1) { return true; } } return false;
a.cc: In function 'bool func(std::string, int*, int)': a.cc:50:22: error: expected '}' at end of input 50 | return false; | ^ a.cc:43:1: note: to match this '{' 43 | { | ^
s844518153
p04045
C++
include <iostream> using namespace std; int main(){ int n,k,ans; int D[10]; cin >> n >> k; for(int i=0;i < k;i++){ cin >> D[i]; } int count = 1,num,flag=1,old_ans; while(1){ ans = n*count; old_ans = ans; flag = 1; while(old_ans > 0){ num = old_ans % 10; for(int i = 0;i<k;i++){ if(num == D[i]){ flag = 0; break; } } if(flag == 0){ count++; break; } old_ans /= 10; } if(flag == 1){ break; } } cout << n*count<<endl; }
a.cc:1:1: error: 'include' does not name a type 1 | include <iostream> | ^~~~~~~ a.cc: In function 'int main()': a.cc:9:5: error: 'cin' was not declared in this scope 9 | cin >> n >> k; | ^~~ a.cc:37:5: error: 'cout' was not declared in this scope; did you mean 'count'? 37 | cout << n*count<<endl; | ^~~~ | count a.cc:37:22: error: 'endl' was not declared in this scope 37 | cout << n*count<<endl; | ^~~~
s653454197
p04045
C++
int minBigger(int i,string& N,string& ans,set<char>& avlb){ while (i >= 0){ for (auto& el : avlb){ if (el > N[i]){ ans[i] = el; return i; } } i--; } } int main() { set<char> avlb = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }; int K; string N; cin >> N >> K; for (int i = 0; i < K; ++i){ char t; cin >> t; avlb.erase(t); } int len = N.length(); N = '0' + N; string ans; ans.resize(len + 1); for (int i = 1; i <= len; ++i){ if (avlb.find(N[i]) == avlb.end()){ i = minBigger(i, N, ans, avlb); int j = i + 1; while (j <= len){ ans[j] = *avlb.begin(); j++; } } else{ ans[i] = N[i]; } } if (ans[0] == '\0'){ ans=ans.substr(1, len + 1); } cout << ans; return 0; }
a.cc:1:21: error: 'string' has not been declared 1 | int minBigger(int i,string& N,string& ans,set<char>& avlb){ | ^~~~~~ a.cc:1:31: error: 'string' has not been declared 1 | int minBigger(int i,string& N,string& ans,set<char>& avlb){ | ^~~~~~ a.cc:1:43: error: 'set' has not been declared 1 | int minBigger(int i,string& N,string& ans,set<char>& avlb){ | ^~~ a.cc:1:46: error: expected ',' or '...' before '<' token 1 | int minBigger(int i,string& N,string& ans,set<char>& avlb){ | ^ a.cc: In function 'int minBigger(int, int&, int&, int)': a.cc:3:33: error: 'avlb' was not declared in this scope 3 | for (auto& el : avlb){ | ^~~~ a.cc:4:35: error: invalid types 'int[int]' for array subscript 4 | if (el > N[i]){ | ^ a.cc:5:36: error: invalid types 'int[int]' for array subscript 5 | ans[i] = el; | ^ a.cc: In function 'int main()': a.cc:14:9: error: 'set' was not declared in this scope 14 | set<char> avlb = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }; | ^~~ a.cc:14:13: error: expected primary-expression before 'char' 14 | set<char> avlb = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }; | ^~~~ a.cc:16:9: error: 'string' was not declared in this scope 16 | string N; | ^~~~~~ a.cc:17:9: error: 'cin' was not declared in this scope 17 | cin >> N >> K; | ^~~ a.cc:17:16: error: 'N' was not declared in this scope 17 | cin >> N >> K; | ^ a.cc:21:17: error: 'avlb' was not declared in this scope 21 | avlb.erase(t); | ^~~~ a.cc:25:15: error: expected ';' before 'ans' 25 | string ans; | ^~~~ | ; a.cc:26:9: error: 'ans' was not declared in this scope 26 | ans.resize(len + 1); | ^~~ a.cc:28:21: error: 'avlb' was not declared in this scope 28 | if (avlb.find(N[i]) == avlb.end()){ | ^~~~ a.cc:43:9: error: 'cout' was not declared in this scope 43 | cout << ans; | ^~~~ a.cc: In function 'int minBigger(int, int&, int&, int)': a.cc:11:1: warning: control reaches end of non-void function [-Wreturn-type] 11 | } | ^
s305455926
p04045
C++
import java.util.*; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int amount = sc.nextInt(); int number = sc.nextInt(); boolean [] discard = new boolean[10]; for(int i = 0; i < number; i ++) { discard[sc.nextInt()] = true; } int result = 0; int remain = 0; int base = 1; while(amount != 0 || remain != 0) { int digit = amount % 10 + remain; int upDigit = digit + 9; while((digit <= upDigit) && discard[digit % 10]) digit ++; remain = digit / 10; digit = digit % 10; result += digit * base; base *= 10; amount /= 10; } System.out.println(result); } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.util.*; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: expected unqualified-id before 'public' 2 | public class Main { | ^~~~~~
s765887499
p04045
C
#include <stdio.h> #include <stdlib.h> #include <limits.h> int int_sort( const void * a , const void * b ) { /* 引数はvoid*型と規定されているのでint型にcastする */ if( *( int * )a < *( int * )b ) { return -1; } else if( *( int * )a == *( int * )b ) { return 0; } return 1; } void delnumber(int K[], const int D_k[], int k){ int K_size = 10; //sizeof(k) / sizeof(k[0]); int D_size = k; //sizeof(D_k) / sizeof(D_k[0]); //printf("%d, %d", K_size, D_size); for(int i = 0; i < K_size; i++){ for(int j = 0; j< D_size; j++){ //printf("i = %d, j = %d\n", i, j); if(K[i] == D_k[j]){ K[i] = INT_MAX; } } } } int makenumber(int K[], int N){ while() return 0; } int main(){ int K[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; int N, k; scanf("%d %d", &N , &k); int D_k[k]; int D_kCounter = 1; for(int i = 0; i<k; i++){ scanf("%d", &D_k[i]); D_kCounter = D_kCounter * D_k[i]; } if(D_kCounter == 362880){ printf("failed"); return -1; } delnumber(K, D_k, k); qsort(K, 10, sizeof(int), int_sort);; return 0; }
main.c: In function 'makenumber': main.c:33:9: error: expected expression before ')' token 33 | while() | ^
s853020058
p04045
Java
import java.util.Scanner; /** * Created by wild on 2016/07/23. */ public class Main { public static void main(String[] args) { //入力 Scanner scan = new Scanner(System.in); String[] tmpstr = scan.next().split(""); int[] money = new int[5]; int tmpcnt = 0; for (int i = 1; i < money.length; i++) { money[i] = Integer.parseInt(tmpstr[tmpcnt]); tmpcnt++; } int num = scan.nextInt(); int[] hate = new int[num]; for (int i = 0; i < hate.length; i++) { hate[i] = scan.nextInt(); } boolean complate = false; boolean equ = false; boolean mbZero = true; while (!complate) { for (int i = 0; i < money.length; i++) { if (i == 0 && mbZero) { continue; } else { mbZero = false; } for (int j = 0; j < hate.length; j++) { if (money[i] == hate[j]) { money[i]++; if (money[i] == 10) { money[i] = 0; money[i - 1]++; equ = true; break; } } } if (equ) { break; } } if (!equ) { complate = true; } else { mbZero = true; equ = false; } } boolean zero = true; for (int tmp : money) { if (tmp == 0 && zero){ continue; }else { zero = false; } System.out.print(tmp); } }
Main.java:68: error: reached end of file while parsing } ^ 1 error
s607746126
p04045
C++
#include <iostream> #include <vector> using namespace std; bool can_pay(int x, vector<int> ds) { for ( ; x > 0; x /= 10) { int digit = x % 10; if (find(begin(ds), end(ds), digit) != end(ds)) { return false; } } return true; } int main() { int n, k; cin >> n >> k; vector<int> ds(k); for (auto &d : ds) { cin >> d; } for (int i = n; i < 1000000; i++) { if (can_pay(i, ds)) { cout << i << endl; break; } } }
a.cc: In function 'bool can_pay(int, std::vector<int>)': a.cc:8:17: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int&)' 8 | if (find(begin(ds), end(ds), digit) != end(ds)) { | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/bits/locale_facets.h:48, from /usr/include/c++/14/bits/basic_ios.h:37, from /usr/include/c++/14/ios:46, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)' 435 | find(istreambuf_iterator<_CharT> __first, | ^~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed: a.cc:8:17: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>' 8 | if (find(begin(ds), end(ds), digit) != end(ds)) { | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
s729678512
p04045
Java
import java.util.ArrayList; import java.util.Scanner; /** * Created by wild on 2016/07/23. */ public class C { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String[] tmpmoney = scan.next().split(""); int[] money = new int[tmpmoney.length]; for (int i = 0; i < tmpmoney.length; i++) { money[i] = Integer.parseInt(tmpmoney[i]); } ArrayList<Integer> mon = new ArrayList<Integer>(); for (int i = money.length - 1; i > -1; i--) mon.add(money[i]); int disnum = scan.nextInt(); int[] num = new int[disnum]; for (int i = 0; i < disnum; i++) { num[i] = scan.nextInt(); } boolean ok = false; for (int i = 0; i < mon.size(); ) { if (mon.get(i) > 9) { if (i == mon.size() - 1) { mon.set(i, 0); mon.add(i + 1, 1); } else { mon.set(i + 1, mon.get(i + 1) + 1); mon.set(i, 0); } } for (int j = 0; j < num.length; j++) { if (mon.get(i) == num[j]) { mon.set(i, mon.get(i) + 1); break; } if(j == num.length-1){ ok = true; break; } } if (ok) { ok = false; i++; } } for (int i = mon.size()-1; i > -1; i--){ System.out.print(mon.get(i)); } } }
Main.java:7: error: class C is public, should be declared in a file named C.java public class C { ^ 1 error
s722050588
p04045
C++
#include <iostream> using namespace std; int main(){ int n,k; bool arr[10] = {}; cin >> n >> k; while(k--){ int d; cin >> d; arr[d] = true; } for(int i = n;i < 10000;i++){ int tmp = i; bool f = true; while(tmp){ if(arr[x % 10]) f = false; x /= 10; } if(f){ cout << i << endl; return 0; } } }
a.cc: In function 'int main()': a.cc:17:32: error: 'x' was not declared in this scope 17 | if(arr[x % 10]) f = false; | ^ a.cc:18:25: error: 'x' was not declared in this scope 18 | x /= 10; | ^
s710127811
p04045
C++
#include <iostream> #include <stdio.h> // printf,scanf #include <stdlib.h> #include <math.h> #include <string> #include <vector> #include <algorithm> //sort,binarySearch #include <functional> #include <iomanip> // setprecision #include <utility> // c+11 Array #include <set> #include <sstream> #include <bits/stdc++.h> #define PI 3.141592653589793238462643383279 #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define pb(x) push_back(x) #define debug(x) cout << #x << " = " << x << endl; #define debret(x) debug(x) ; return 0; using namespace std; int main(void){ string pay; int hate; cin >> pay >> hate; int pay_2_i[pay.size()]; int copy = stoi(pay); REP(i,pay.size()){ pay_2_i[i] = pay[i] - '0'; } int h[hate]; REP(i,hate){ cin >> h[i]; } int j; REP(i,pay.size()){ for(j = 0;j<hate;j++){ if(pay_2_i[i] == h[j]){ pay_2_i[i]++; pay_2_i[i] = pay_2_i[i] % 10; j = -1; } } } int ans = 0; for(int i = 0; i < pay.size();i++){ ans += pay_2_i[pay.size()-1-i]*pow(10,i); } sort(pay_2_i,pay_2_i+pay.size()); if(copy > ans){ REP(i,copy.size()) if(pay_2_i[i] != 0){ cout << pay_2_i[i]; break; } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:58:20: error: request for member 'size' in 'copy', which is of non-class type 'int' 58 | REP(i,copy.size()) | ^~~~ a.cc:15:37: note: in definition of macro 'FOR' 15 | #define FOR(i,a,b) for(int i=(a);i<(b);++i) | ^ a.cc:58:9: note: in expansion of macro 'REP' 58 | REP(i,copy.size()) | ^~~
s318854170
p04045
C++
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> d(k); for(int i = 0;i < k;i++){ cin >> d[i]; } vector<int> uk(10 - k); for(int i = 0;i < 10;i++){ if(!binary_search(d.begin(), d.end(), i)){ uk.push_back(i); } } vector<int> r(4); r[0] = n % 10; n /= 10; r[1] = n % 10; n /= 10; r[2] = n % 10; n /= 10; r[3] = n % 10; n /= 10; bool f = false; int ans = 0; if(!f){ bool sf; for(int i = 0;i <= r[3];i++){ if(binary_search(d.begin(), d.end(), r[3] + i)){ sf = true; }else{ ans += ((r[3] + i) * 1000); if(i == 0){ f = true; } sf = false; break; } } if(sf){ ans += 10000; f = true; } } if(!f){ for(int i = 0;i <= r[2];i++){ if(binary_search(d.begin(), d.end(), r[2] + i)){ }else{ ans += ((r[2] + i) * 100); if(i == 0){ f = true; } break; } } }else{ for(int i = 0;i < 10 - k;i++){ if(uk[i] >= r[2]){ ans += uk[i] * 100; break; } } } if(!f){ for(int i = 0;i <= r[1];i++){ if(binary_search(d.begin(), d.end(), r[1] + i)){ }else{ ans += ((r[1] + i) * 10); if(i == 0){ f = true; } break; } } }else{ for(int i = 0;i < 10 - k;i++){ if(uk[i] >= r[2]){ ans += uk[i] * 10; break; } } } if(!f){ for(int i = 0;i <= r[0];i++){ if(binary_search(d.begin(), d.end(), r[0] + i)){ }else{ ans += r[0] + i); if(i == 0){ f = true; } break; } } }else{ for(int i = 0;i < 10 - k;i++){ if(uk[i] >= r[2]){ ans += uk[i]; break; } } } cout << ans; }
a.cc: In function 'int main()': a.cc:99:48: error: expected ';' before ')' token 99 | ans += r[0] + i); | ^ | ;
s611473958
p04045
C++
#include <bits/stdc++.h> #define loop(i,a,b) for(int i=(a);i<(b);++i) #define rep(i,n) loop(i,0,n) #define dump(x) cerr << #x << " = " << (x) << endl #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << endl using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; vector<int> hate(k); rep(i,k) cin >> hate[i]; vector<int> like = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; rep(i,k){ like.erase(remove(like.begin(), like.end(), hate[i]), like.end()); } string str_n = to_string(n); int kuriagari = 0; sort(like.begin(), like.end()); int max_like = *max_element(like.begin(), like.end()); int min_like = *min_element(like.begin(), like.end()); vector<int> ans; for(int i = str_n.size() -1;i>=0;i--){ int t = str_n[i] - '0'; int kk = 0; if(kuriagari == 1){ t++; } if(t >= 10){ t = 0; kk = 1; } if( t > max_like || kk = 1){ kuriagari = 1; ans.push_back(min_like); }else{ kuriagari = 0; ans.push_back(*lower_bound(like.begin(), like.end(), t)); } } if(kuriagari == 1){ ans.push_back(*upper_bound(like.begin(), like.end(), 0)); } for(int i = ans.size()-1;i>=0;i--){ cout << ans[i] ; } cout << endl; return 0; }
a.cc: In function 'int main()': a.cc:36:22: error: lvalue required as left operand of assignment 36 | if( t > max_like || kk = 1){ | ~~~~~~~~~~~~~^~~~~
s019307018
p04045
C++
int SolveCSub(int pay, int digit, const bool hate[10], int N){ if(digit <= 0){ if(pay >= N) return pay; else return 100000; } int iret = 100000; for(int i = 0; i < 10; i++){ if(hate[i] && !(i == 0 && digit == 10000)) continue; int a = SolveCSub(pay + i * digit, digit/10, hate, N); if (a < iret) iret = a; } return iret; } void SolveC(){ bool hate[10] = {false}; int N, K; cin >> N >> K; for(int i = 0; i < K; i++){ int a; cin >> a; hate[a] = true; } cout << SolveCSub(0,100000,hate, N) << endl; } //int dp[100001]; int main(){ SolveC(); /* const int kDiv = 1000000007; int H, W, A, B; cin >> H >> W >> A >> B; dp[0] = 1; for(int y = 0; y < H-A; y++) for(int x = 0; x < W; x++) dp[x+1] = (dp[x+1] + dp[x]) % kDiv; for(int y = 0; y < A; y++) for(int x = B; x < W; x++) dp[x+1] = (dp[x+1] + dp[x]) % kDiv; cout << dp[W-1] << endl; */ return 0; }
a.cc: In function 'void SolveC()': a.cc:19:3: error: 'cin' was not declared in this scope 19 | cin >> N >> K; | ^~~ a.cc:26:3: error: 'cout' was not declared in this scope 26 | cout << SolveCSub(0,100000,hate, N) << endl; | ^~~~ a.cc:26:42: error: 'endl' was not declared in this scope 26 | cout << SolveCSub(0,100000,hate, N) << endl; | ^~~~
s932075628
p04045
Java
import java.util.*; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int K = sc.nextInt(); List<Integer> Dlist = new ArrayList<>(); for(int i=0; i<K; i++){ Diist.add(sc.nextInt()); } for(int i=N;i==10000;i++){ while(i/10 != 0){ for(int D: Dlist){ if(D== i%10){ break; } } } System.out.println(i); break; } } }
Main.java:10: error: cannot find symbol Diist.add(sc.nextInt()); ^ symbol: variable Diist location: class Main 1 error
s367275041
p04045
C
#include<stdio.h> #include<stdlib.h> #include<string.h> int cmp(const void *a, const void *b){ return *(const int*)a-*(const int*)b; } int main(){ int i,j,n,k; char s[5]; char a[10]; int len; int d[10]; scanf("%d%d",&n,&k); itoa(n,s,10); for(i=k;i--;)scanf("%d",&d[i]); qsort(d,k,sizeof(d[0]),cmp); for(i=k;i--;)a[i]=d[i]+'0'; len = strlen(s); for(i = 0;i < len;i++){ for(j = 0;j < k;j++){ if(s[i]==a[j]){ s[i]++; }else break; } } printf("%d\n",atoi(s)); return 0; }
main.c: In function 'main': main.c:17:9: error: implicit declaration of function 'itoa' [-Wimplicit-function-declaration] 17 | itoa(n,s,10); | ^~~~
s556929384
p04045
Java
import java.util.*; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int K = sc.nextInt(); List<int> Dlist = new ArrayList<>(); for(int i=0; i<K; i++){ Diist.add(sc.nextInt()); } for(int i=N;i==10000;i++){ while(i/10 != 0){ for(int D: Dlist){ if(D== i%10){ break; } } } System.out.println(i); break; } } }
Main.java:8: error: unexpected type List<int> Dlist = new ArrayList<>(); ^ required: reference found: int Main.java:10: error: cannot find symbol Diist.add(sc.nextInt()); ^ symbol: variable Diist location: class Main 2 errors
s367798798
p04045
Java
import java.util.*; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int K = sc.nextInt(); List<int> Dlist = new ArrayList<>(); for(int i=0; i<K; i++){ Diist.add(sc.nextInt(); } for(int i=N;i==10000;i++){ while(i/10 != 0){ for(int D: Dlist){ if(D== i%10){ break; } } } System.out.println(i); break; } } }
Main.java:10: error: ')' or ',' expected Diist.add(sc.nextInt(); ^ 1 error
s096441387
p04045
Java
import java.util.*; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int K = sc.nextInt(); List<int> Dlist = new ArrayList<>(); for(int i=0; i<K; i++){ Diist.add(K); } for(int i=N;i==10000;i++){ while(i/10 != 0){ for(int D: Dlist){ if(D== i%10){ break; } } } System.out.println(i); break; } } }
Main.java:8: error: unexpected type List<int> Dlist = new ArrayList<>(); ^ required: reference found: int Main.java:10: error: cannot find symbol Diist.add(K); ^ symbol: variable Diist location: class Main 2 errors
s473595024
p04045
Java
import java.util.*; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int K = sc.nextInt(); List<int> Dlist = new ArrayList<>(); for(int i=0; i<K; i++){ Diist.add(K); } for(int i=N;i==10000;i++){ while(i/10 != 0){ for(int D: Dlist){ if(D== i%10){ break; } } } System.out.println(i); break; } } } }
Main.java:25: error: class, interface, enum, or record expected } ^ 1 error
s813326395
p04045
C++
#include <iostream> #include <queue> #include <map> #include <list> #include <vector> #include <string> #include <limits> #include <cassert> #include <fstream> #include <cstring> #include <bitset> #include <iomanip> #include <algorithm> #include <functional> #include <cstdio> #include <ciso646> #include <array> using namespace std; #define FOR(i,a,b) for (int i=(a);i<(b);i++) #define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--) #define REP(i,n) for (int i=0;i<(n);i++) #define RREP(i,n) for (int i=(n)-1;i>=0;i--) #define inf 0x3f3f3f3f #define uinf 0x3f3f3f3f3f3f3f3f #define CLEAR(a) a = decltype(a)() #define MP make_pair #define ALL(a) (a).begin(),(a).end() #define pii pair<int ,int> #define pcc pair<char,char> #define pic pair<int,char> #define pci pair<char,int> #define VS vector<string> #define VI vector<int> #define VVI vector<vector<int>> #define DEBUG(x) cout<<#x<<": "<<x<<endl #define pi 2*acos(0.0) #define INFILE() freopen("in.txt","r",stdin) #define OUTFILE() freopen("out.txt","w",stdout) #define ll long long #define ull unsigned long long #define eps 1e-14 #define FIN std::ifstream cin("D:\input.txt") vector<int> A; int N; int siz; int d(vector<int> nums) { nums.push_back(-1000000); for (auto a : A) { nums.back() = a; int num = 0; if (siz == nums.size()) { REP(i, nums.size()) num += nums[i] * pow(10, i); } else { num = d(nums); } if (N <= num) return num; } return -1; } signed main(void) { cin >> N; siz = (int)log10(N)+1; int K; cin >> K; bitset<10> D; REP(i, K) { int a; cin >> a; D[a] = true; } REP(i, 10) if (not D[i]) A.push_back(i); int res = d(vector<int>()); if (res >= 0) { cout << res << endl; return 0; } if (A[0] == 0) { cout << A[1]; } else cout << A[0]; REP(i, siz-1) cout << A[0]; cout << endl; return 0; }
a.cc: In function 'int d(std::vector<int>)': a.cc:57:62: error: 'pow' was not declared in this scope 57 | REP(i, nums.size()) num += nums[i] * pow(10, i); | ^~~ a.cc: In function 'int main()': a.cc:69:20: error: 'log10' was not declared in this scope 69 | siz = (int)log10(N)+1; | ^~~~~
s693234138
p04045
C++
import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner scanner = new Scanner(System.in); int N, K; N = scanner.nextInt(); K = scanner.nextInt(); String[] D = new String[K]; for (int i = 0; i < K; i++) { D[i] = scanner.next(); } a: while (true) { for (int i = 0; i < D.length; i++) { if (Integer.toString(N).contains(D[i])) { N++; continue a; } } break; } System.out.println(N); } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.util.Scanner; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: expected unqualified-id before 'public' 3 | public class Main { | ^~~~~~
s458254054
p04045
C++
#include<cstdio> #include<iostream> #include<cmath> #include<vector> #include <cstdlib> #include<string> #include<algorithm> #include<map> #define ll long long #define LL long long #define ULL unsigned long long #define ull unsigned long long #define FOR(i,a,b) for(int i=a;i<b;i++) #define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--) #define REP(i,n) for(int i=0;i<n;i++) #define RREP(i,n) for(int i=(n)-1;i>=0;i--) using namespace std; int main() { int ans[100]; int K; int num_count; int j=0; int D[10]; bool judge[10] = {}; int tmpnum = 10; char N[10000] = {}; int tmp[10] = {}; cin >> N >> K; REP(i, 10) { judge[i] = true; } REP(i, K) { cin >> D[i]; judge[D[i]] = false; } REP(i, 10) { if (judge[i] == true) { tmp[j] = i; j++; } } num_count = strlen(N); REP(i, num_count) { REP(j, 10 -K) { if (j == 0&& N[i] - 48 <= tmp[j]) { tmpnum = tmp[j]; } if (N[i]-48 <= tmp[j]&&tmpnum>tmp[j]) { tmpnum = tmp[j]; } } ans[i] = tmpnum; } REP(i, strlen(N)) { cout << ans[i]; } cout << endl; return 0; }
a.cc: In function 'int main()': a.cc:46:21: error: 'strlen' was not declared in this scope 46 | num_count = strlen(N); | ^~~~~~ a.cc:9:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 8 | #include<map> +++ |+#include <cstring> 9 |
s544477215
p04045
C++
#include<cstdio> #include<iostream> #include<cmath> #include<vector> #include <cstdlib> #include<string> #include<algorithm> #include<map> #define ll long long #define LL long long #define ULL unsigned long long #define ull unsigned long long #define FOR(i,a,b) for(int i=a;i<b;i++) #define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--) #define REP(i,n) for(int i=0;i<n;i++) #define RREP(i,n) for(int i=(n)-1;i>=0;i--) using namespace std; int main() { int ans[100]; int K; int num_count; int j=0; int D[10]; bool judge[10] = {}; int tmpnum = 10; char N[10000] = {}; int tmp[10] = {}; cin >> N >> K; REP(i, 10) { judge[i] = true; } REP(i, K) { cin >> D[i]; judge[D[i]] = false; } REP(i, 10) { if (judge[i] == true) { tmp[j] = i; j++; } } num_count = strlen(N); REP(i, num_count) { REP(j, 10 -K) { if (N[i]-48 <= tmp[j]&&tmpnum>tmp[j]) { tmpnum = tmp[j]; } } ans[i] = tmpnum; } REP(i, strlen(N)) { cout << ans[i]; } cout << endl; return 0; }
a.cc: In function 'int main()': a.cc:46:21: error: 'strlen' was not declared in this scope 46 | num_count = strlen(N); | ^~~~~~ a.cc:9:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 8 | #include<map> +++ |+#include <cstring> 9 |
s992115366
p04045
C++
#include<cstdio> #include<iostream> #include<cmath> #include<vector> #include <cstdlib> #include<string> #include<algorithm> #include<map> #define ll long long #define LL long long #define ULL unsigned long long #define ull unsigned long long #define FOR(i,a,b) for(int i=a;i<b;i++) #define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--) #define REP(i,n) for(int i=0;i<n;i++) #define RREP(i,n) for(int i=(n)-1;i>=0;i--) using namespace std; int main() { int ans[100]; int K; int num_count; int j=0; int D[10]; bool judge[10] = {}; int tmpnum = 10; char N[10000] = {}; int tmp[10] = {}; cin >> N >> K; REP(i, 10) { judge[i] = true; } REP(i, K) { cin >> D[i]; judge[D[i]] = false; } REP(i, 10) { if (judge[i] == true) { tmp[j] = i; j++; } } REP(i, strlen(N)) { REP(j, 10 -K) { if (N[i]-48 <= tmp[j]&&tmpnum>tmp[j]) { tmpnum = tmp[j]; } } ans[i] = tmpnum; } REP(i, strlen(N)) { cout << ans[i]; } cout << endl; return 0; }
a.cc: In function 'int main()': a.cc:47:16: error: 'strlen' was not declared in this scope 47 | REP(i, strlen(N)) { | ^~~~~~ a.cc:16:32: note: in definition of macro 'REP' 16 | #define REP(i,n) for(int i=0;i<n;i++) | ^ a.cc:9:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 8 | #include<map> +++ |+#include <cstring> 9 | a.cc:56:16: error: 'strlen' was not declared in this scope 56 | REP(i, strlen(N)) { | ^~~~~~ a.cc:16:32: note: in definition of macro 'REP' 16 | #define REP(i,n) for(int i=0;i<n;i++) | ^ a.cc:56:16: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 56 | REP(i, strlen(N)) { | ^~~~~~ a.cc:16:32: note: in definition of macro 'REP' 16 | #define REP(i,n) for(int i=0;i<n;i++) | ^
s976787730
p04045
C++
#include <sstream> #include <string> #include <vector> #include <algorithm> #include <numeric> #include <set> #include <map> #include <queue> #include <iostream> #include <cstdio> #include <cmath> #include <cstring> using namespace std; int main(){ int N,K,tmp; vector<int> D; string stream ss; string s; bool flg=true; cin>>N>>K; for(int i=0;i<K;i++){ cin>>tmp; D.push_back(tmp); } for(int i=N;i<N*10;i++){ ss<<i; s=ss.str(); flg=true; for(int j=0;j<s.size();j++){ for(int k=0;k<K;k++){ if(s[j]==D[k]){ flg=false; } } } if(flg){ cout<<i<<endl; return 0; } } return 0; }
a.cc: In function 'int main()': a.cc:20:23: error: expected initializer before 'ss' 20 | string stream ss; | ^~ a.cc:31:17: error: 'ss' was not declared in this scope; did you mean 's'? 31 | ss<<i; | ^~ | s
s010981973
p04045
C++
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <queue> #include <stack> #include <complex> #include <functional> #include <cmath> using namespace std; using ull = unsigned long long; using ll = long long; int main(){ int N, K; cin >> N >> K; vector<string> isUnuse; for (int i = 0; i < K; i++){ string temp; cin >> temp; isUnuse.emplace_back(temp); } while (1){ string str = to_string(N); int count = 0; for (auto&& a : isUnuse){ if (strstr(str.c_str(), a.c_str()) == NULL){ count++; } else{ N++; break; } } if (count == isUnuse.size()){ cout << str << endl; return 0; } } }
a.cc: In function 'int main()': a.cc:34:29: error: 'strstr' was not declared in this scope 34 | if (strstr(str.c_str(), a.c_str()) == NULL){ | ^~~~~~ a.cc:11:1: note: 'strstr' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 10 | #include <cmath> +++ |+#include <cstring> 11 |
s623328255
p04046
C++
#include <stdio.h> #include <stdlib.h> // _____ _ _ __ __ ____ __ _ #include <string.h> // / ____| | | | | | \ / | / \ | \ | | #include <math.h> // | |___ | | | | | \/ | / _ \ | . \ | | #include <stdbool.h> // \____ \ | | | | | |\__/| | | /_\ | | |\ \| | #include <time.h> // ____| | | \__/ | | | | | | __ | | | \ ` | #include <limits.h> // |_____/ \______/ |_| |_| |__| |__| |_| \__| #include <ctype.h> // #include <assert.h> == #define newline printf("\n") #define space printf(" ") #define iter(x,a,b) for(int x=a;x<=b;x++) #define FOR(x,n) for(int x=0;x<n;x++) #define For(x,n) FOR(x,n) #define caseprint printf("Case #%d: ",test+1) #define inverse(a) power(a,mod-2) #define scan(a) scanf("%d",&a) #define print(a) printf("%lld",((ll)a)) #define println(a) printf("%lld\n",((ll)a)) #define read(arr,maxN) FOR(x,maxN) scan(arr[x]) #define write(arr,maxN) FOR(x,maxN) {print(arr[x]);space;} #define fill(arr,maxN,value) FOR(x,maxN) arr[x] = value #define SORT123(arr,maxN) qsort(arr,maxN,sizeof(int),ascending) #define SORT321(arr,maxN) qsort(arr,maxN,sizeof(int),descending) #define newIntArray(n) (int*)malloc(sizeof(int)*n) #define newLLArray(n) (ll *)malloc(sizeof(ll)*n) typedef unsigned long long int ull; typedef long long int ll; const ll mod = 1000000007; // 10**9+7 static inline void swap_int(int *a, int *b) {int temp=*a;*a=*b;*b=temp;} static inline void swap_char(char *a, char *b) {char c=*a;*a=*b;*b=c;} static inline void swap_long(ll *a, ll *b) {ll temp=*a;*a=*b;*b=temp;} static inline int set_bit_count(ll n) {int ans=0;for(;n>0;n/=2,ans+=n%2);return ans;} static inline ll gcd(ll a, ll b) {for(ll rem;b>0;rem=a%b,a=b,b=rem);return a;} static inline ll lcm(ll a, ll b) {return (a*b)/(gcd(a,b));} static inline ll max(ll a, ll b) {return (a>b?a:b);} static inline ll min(ll a, ll b) {return (a<b?a:b);} static inline ll mul(ll a, ll b) {return ((a%mod*b%mod)%mod);} static inline ll add(ll a, ll b) {return ((a%mod+b%mod)%mod);} static inline ll sub(ll a, ll b) {return ((a%mod-b%mod)+mod)%mod;} static inline int sum_of_digits(ll n) {return n>0?n%10+sum_of_digits(n/10):0;} static inline int number_of_digits(ll n) {return n>0?1+number_of_digits(n/10):0;} int ascending (const void *a, const void *b) {return *(int*)a-*(int*)b>=0?1:-1;} int descending(const void *a, const void *b) {return *(int*)b-*(int*)a>=0?1:-1;} ll power(ll x, ll y) { ll result=1; for(;y>0;y>>=1,x=mul(x,x)) { if(y&1) result=mul(result,x); } return result; } bool is_prime(ll n) { if(n==0 or n==1) return false; else if(n==2 or n==3) return true; else if(n%2==0 or n%3==0) return false; for(int i=5;i<=sqrt(n);i+=6) if(n%i==0 or n%(i+2)==0) return false; return true; } typedef struct tuple { int first; int second; }tuple; int compare(const void*a,const void*b) { return ((*(tuple*)a).first-(*(tuple*)b).first)>=0?1:-1; } #define size 1000003 // 10**6+3 ll fact[size] = {1}; void compute_factorials() { for(int i=1;i<size;i++) fact[i] = mul(fact[i-1],i); } ll ncr_mod_p(ll n, ll r) { if(r == 0) return 1; return mul(mul(fact[n],inverse(fact[r])), inverse(fact[n - r])); } ll number_of_ways(ll a, ll b, ll x, ll y) { return ncr_mod_p(x+y-(a+b),x-a); } void solve() { int h,w,a,b; scan(h); scan(w); scan(a); scan(b); int y = h-a; int x = w-b; ll ans = 0; for(int i=1;i<=y;i++) ans = add(ans,mul(number_of_ways(1LL,1LL,b,i),number_of_ways(b+1,i,w,h))); print(ans); } int main() { int t=1; compute_factorials(); if(!t) scan(t); For(test,t) { solve(); } return 0; }
a.cc:10:65: error: expected unqualified-id before '==' token 10 | == | ^~
s524100024
p04046
C++
#include <stdio.h> #include <stdlib.h> // _____ _ _ __ __ ____ __ _ #include <string.h> // / ____| | | | | | \ / | / \ | \ | | #include <math.h> // | |___ | | | | | \/ | / _ \ | . \ | | #include <stdbool.h> // \____ \ | | | | | |\__/| | | /_\ | | |\ \| | #include <time.h> // ____| | | \__/ | | | | | | __ | | | \ ` | #include <limits.h> // |_____/ \______/ |_| |_| |__| |__| |_| \__| #include <ctype.h> // #include <assert.h> #define and && #define or || #define not ! #define is == #define newline printf("\n") #define space printf(" ") #define iter(x,a,b) for(int x=a;x<=b;x++) #define FOR(x,n) for(int x=0;x<n;x++) #define For(x,n) FOR(x,n) #define caseprint printf("Case #%d: ",test+1) #define inverse(a) power(a,mod-2) #define scan(a) scanf("%d",&a) #define print(a) printf("%lld",((ll)a)) #define println(a) printf("%lld\n",((ll)a)) #define read(arr,maxN) FOR(x,maxN) scan(arr[x]) #define write(arr,maxN) FOR(x,maxN) {print(arr[x]);space;} #define fill(arr,maxN,value) FOR(x,maxN) arr[x] = value #define SORT123(arr,maxN) qsort(arr,maxN,sizeof(int),ascending) #define SORT321(arr,maxN) qsort(arr,maxN,sizeof(int),descending) #define newIntArray(n) (int*)malloc(sizeof(int)*n) #define newLLArray(n) (ll *)malloc(sizeof(ll)*n) typedef unsigned long long int ull; typedef long long int ll; const ll mod = 1000000007; // 10**9+7 static inline void swap_int(int *a, int *b) {int temp=*a;*a=*b;*b=temp;} static inline void swap_char(char *a, char *b) {char c=*a;*a=*b;*b=c;} static inline void swap_long(ll *a, ll *b) {ll temp=*a;*a=*b;*b=temp;} static inline int set_bit_count(ll n) {int ans=0;for(;n>0;n/=2,ans+=n%2);return ans;} static inline ll gcd(ll a, ll b) {for(ll rem;b>0;rem=a%b,a=b,b=rem);return a;} static inline ll lcm(ll a, ll b) {return (a*b)/(gcd(a,b));} static inline ll max(ll a, ll b) {return (a>b?a:b);} static inline ll min(ll a, ll b) {return (a<b?a:b);} static inline ll mul(ll a, ll b) {return ((a%mod*b%mod)%mod);} static inline ll add(ll a, ll b) {return ((a%mod+b%mod)%mod);} static inline ll sub(ll a, ll b) {return ((a%mod-b%mod)+mod)%mod;} static inline int sum_of_digits(ll n) {return n>0?n%10+sum_of_digits(n/10):0;} static inline int number_of_digits(ll n) {return n>0?1+number_of_digits(n/10):0;} int ascending (const void *a, const void *b) {return *(int*)a-*(int*)b>=0?1:-1;} int descending(const void *a, const void *b) {return *(int*)b-*(int*)a>=0?1:-1;} ll power(ll x, ll y) { ll result=1; for(;y>0;y>>=1,x=mul(x,x)) { if(y&1) result=mul(result,x); } return result; } bool is_prime(ll n) { if(n==0 or n==1) return false; else if(n==2 or n==3) return true; else if(n%2==0 or n%3==0) return false; for(int i=5;i<=sqrt(n);i+=6) if(n%i==0 or n%(i+2)==0) return false; return true; } typedef struct tuple { int first; int second; }tuple; int compare(const void*a,const void*b) { return ((*(tuple*)a).first-(*(tuple*)b).first)>=0?1:-1; } #define size 1000003 // 10**6+3 ll fact[size] = {1}; void compute_factorials() { for(int i=1;i<size;i++) fact[i] = mul(fact[i-1],i); } ll ncr_mod_p(ll n, ll r) { if(r == 0) return 1; return mul(mul(fact[n],inverse(fact[r])), inverse(fact[n - r])); } ll number_of_ways(ll a, ll b, ll x, ll y) { return ncr_mod_p(x+y-(a+b),x-a); } void solve() { int h,w,a,b; scan(h); scan(w); scan(a); scan(b); int y = h-a; int x = w-b; ll ans = 0; for(int i=1;i<=y;i++) ans = add(ans,mul(number_of_ways(1LL,1LL,b,i),number_of_ways(b+1,i,w,h))); print(ans); } int main() { int t=1; compute_factorials(); if(!t) scan(t); For(test,t) { solve(); } return 0; }
a.cc:12:9: error: "and" cannot be used as a macro name as it is an operator in C++ 12 | #define and && | ^~~ a.cc:13:9: error: "or" cannot be used as a macro name as it is an operator in C++ 13 | #define or || | ^~ a.cc:14:9: error: "not" cannot be used as a macro name as it is an operator in C++ 14 | #define not ! | ^~~
s041143522
p04046
C++
typedef struct Combinatorics{ private: long long MOD = 1e9 + 7; vector<long long> fac, inv_fac; public: Combinatorics(int N, long long MOD = 1e9 + 7): fac(N + 1, 1ll), inv_fac(N + 1, 1ll), MOD(MOD){ for(int i = 2; i <= N; i ++){ fac[i] = fac[i - 1] * i % MOD; inv_fac[i] = mypow(fac[i], MOD - 2); } } long long C(int n, int k){ return fac[n] * inv_fac[k] % MOD * inv_fac[n - k] % MOD; } private: long long mypow(int x, int k){ if(k == 0) return 1ll; long long t = mypow(x, k / 2); long long res = t * t % MOD; if(k % 2) res = res * x % MOD; return res; } }Comb; class Solution{ private: const long long MOD = 1e9 + 7; public: int ways(int H, int W, int A, int B){ Combinatorics c(2 * (H + W), MOD); long long res = 0ll; for(int j = B + 1; j <= W; j ++) { long long a = c.C(H - A + j - 2, j - 1); long long b = c.C(W - j + 1 + A - 2, A - 1); res += a * b % MOD; res %= MOD; } return res; } };
a.cc:5:5: error: 'vector' does not name a type 5 | vector<long long> fac, inv_fac; | ^~~~~~ a.cc: In constructor 'Combinatorics::Combinatorics(int, long long int)': a.cc:8:52: error: class 'Combinatorics' does not have any field named 'fac' 8 | Combinatorics(int N, long long MOD = 1e9 + 7): fac(N + 1, 1ll), inv_fac(N + 1, 1ll), MOD(MOD){ | ^~~ a.cc:8:69: error: class 'Combinatorics' does not have any field named 'inv_fac' 8 | Combinatorics(int N, long long MOD = 1e9 + 7): fac(N + 1, 1ll), inv_fac(N + 1, 1ll), MOD(MOD){ | ^~~~~~~ a.cc:11:13: error: 'fac' was not declared in this scope 11 | fac[i] = fac[i - 1] * i % MOD; | ^~~ a.cc:12:13: error: 'inv_fac' was not declared in this scope 12 | inv_fac[i] = mypow(fac[i], MOD - 2); | ^~~~~~~ a.cc: In member function 'long long int Combinatorics::C(int, int)': a.cc:17:16: error: 'fac' was not declared in this scope 17 | return fac[n] * inv_fac[k] % MOD * inv_fac[n - k] % MOD; | ^~~ a.cc:17:25: error: 'inv_fac' was not declared in this scope 17 | return fac[n] * inv_fac[k] % MOD * inv_fac[n - k] % MOD; | ^~~~~~~
s179975966
p04046
C++
for (int i = B+1; i <= W; ++i) { int inc = mul(C(H - A + i - 2, i - 1), C(A + W - i - 1, A - 1)); res = add(res, inc); }
a.cc:1:4: error: expected unqualified-id before 'for' 1 | for (int i = B+1; i <= W; ++i) { | ^~~ a.cc:1:22: error: 'i' does not name a type 1 | for (int i = B+1; i <= W; ++i) { | ^ a.cc:1:30: error: expected unqualified-id before '++' token 1 | for (int i = B+1; i <= W; ++i) { | ^~
s199579569
p04046
Java
import com.sun.istack.internal.Nullable; import java.io.*; import java.util.*; /** * Created by Katushka on 11.03.2020. */ public class Main { static int[] readArray(int size, InputReader in) { int[] a = new int[size]; for (int i = 0; i < size; i++) { a[i] = in.nextInt(); } return a; } static long[] readLongArray(int size, InputReader in) { long[] a = new long[size]; for (int i = 0; i < size; i++) { a[i] = in.nextLong(); } return a; } static long c(int n, int k, long mod, Map<Integer, Map<Integer, Long>> cache, Map<Long, Long> invs) { k = Math.min(k, n - k); if (cache != null && cache.containsKey(n) && cache.get(n).containsKey(k)) { return cache.get(n).get(k); } long nn = 1; for (long i = n - k + 1; i < n + 1; i++) { nn = nn * i % mod; } long kk = 1; for (int t = 1; t < k + 1; t++) { kk = kk * inv(t, mod, invs) % mod; } long result = nn * kk % mod; if (cache != null) { if (!cache.containsKey(n)) { cache.put(n, new HashMap<>()); } cache.get(n).put(k, result); } return result; } private static long fastPow(long x, long y, long mod) { if (x == 1) { return 1; } if (y == 0) { return 1; } long p = fastPow(x, y / 2, mod) % mod; p = p * p % mod; if (y % 2 == 1) { p = p * x % mod; } return p; } private static long inv(long x, long mod, @Nullable Map<Long, Long> cache) { if (cache != null) { if (!cache.containsKey(x)) { cache.put(x, fastPow(x, mod - 2, mod)); } return cache.get(x); } else { return fastPow(x, mod - 2, mod); } } static final long MOD = 1000000007; public static void main(String[] args) throws FileNotFoundException { InputReader in = new InputReader(System.in); PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); int n = in.nextInt(); int m = in.nextInt(); int a = in.nextInt(); int b = in.nextInt(); Map<Long, Long> invs = new HashMap<>(); long prev = c(n - a - 1 + b, b, MOD, null, invs) * c(a + m - b - 1, a, MOD, null, invs) % MOD; long ans = prev; for (int j = 0; j < Math.min(n - a - 1, m - b - 1); j++) { prev = prev * (n - a - j - 1) % MOD; prev = prev * (m - b - j - 1) % MOD; prev = prev * inv(b + j + 1, MOD, invs) % MOD; prev = prev * inv(a + j + 1, MOD, invs) % MOD; ans = (ans + prev) % MOD; } out.println(ans); out.close(); } private static boolean solve(int n, long[][] moves) { Map<Long, Map<Long, Long>> graph = new HashMap<>(); for (int i = 0; i < n; i++) { if (!graph.containsKey(moves[i][0])) { graph.put(moves[i][0], new HashMap<>()); } if (!graph.containsKey(moves[i][1])) { graph.put(moves[i][1], new HashMap<>()); } if (graph.get(moves[i][0]).containsKey(moves[i][1]) && graph.get(moves[i][0]).get(moves[i][1]) != moves[i][2]) { return false; } graph.get(moves[i][0]).put(moves[i][1], moves[i][2]); graph.get(moves[i][1]).put(moves[i][0], moves[i][2]); } Set<Long> notVisited = new HashSet<>(graph.keySet()); while (!notVisited.isEmpty()) { long v = notVisited.iterator().next(); Map<Long, Integer> colors = new HashMap<>(); colors.put(v, 1); if (!dfs(v, graph, notVisited, colors)) { return false; } } return true; } private static boolean dfs(long v, Map<Long, Map<Long, Long>> graph, Set<Long> notVisited, Map<Long, Integer> colors) { notVisited.remove(v); boolean result = true; for (Long u : graph.get(v).keySet()) { if (notVisited.contains(u)) { if (graph.get(v).get(u) == 1L) { colors.put(u, 1 - colors.get(v)); } else { colors.put(u, colors.get(v)); } if (!dfs(u, graph, notVisited, colors)) { result = false; } } else { if (graph.get(v).get(u) == 1L && colors.get(v) != 1 - colors.get(u)) { result = false; } if (graph.get(v).get(u) == 0L && !colors.get(v).equals(colors.get(u))) { result = false; } } } return result; } private static void outputArray(long[] ans, PrintWriter out) { StringBuilder str = new StringBuilder(); for (long an : ans) { str.append(an).append(" "); } out.println(str); } private static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenizer = null; } public String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { createTokenizer(); } return tokenizer.nextToken(); } private void createTokenizer() { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } public String nextWord() { return next(); } public String nextString() { try { return reader.readLine(); } catch (IOException e) { throw new RuntimeException(e); } } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public char nextChar() { return next().charAt(0); } public int[] nextInts() { if (tokenizer == null || !tokenizer.hasMoreTokens()) { createTokenizer(); } List<Integer> res = new ArrayList<>(); while (tokenizer.hasMoreElements()) { res.add(Integer.parseInt(tokenizer.nextToken())); } int[] resArray = new int[res.size()]; for (int i = 0; i < res.size(); i++) { resArray[i] = res.get(i); } return resArray; } } }
Main.java:1: error: package com.sun.istack.internal does not exist import com.sun.istack.internal.Nullable; ^ Main.java:68: error: cannot find symbol private static long inv(long x, long mod, @Nullable Map<Long, Long> cache) { ^ symbol: class Nullable location: class Main 2 errors
s415849012
p04046
C++
10 7 3 4
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 10 7 3 4 | ^~
s137818977
p04046
C++
/* ▓█████▄ ▄████▄ ▓██ ██▓ ██▓███ ██░ ██ ▓█████ ██▀███ ▒██▀ ██▌▒██▀ ▀█ ▒██ ██▒▓██░ ██▒▓██░ ██▒▓█ ▀ ▓██ ▒ ██▒ ░██ █▌▒▓█ ▄ ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███ ▓██ ░▄█ ▒ ░▓█▄ ▌▒▓▓▄ ▄██▒ ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█ ▄ ▒██▀▀█▄ ░▒████▓ ▒ ▓███▀ ░ ░ ██▒▓░▒██▒ ░ ░░▓█▒░██▓░▒████▒░██▓ ▒██▒ ▒▒▓ ▒ ░ ░▒ ▒ ░ ██▒▒▒ ▒▓▒░ ░ ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░ ░ ▒ ▒ ░ ▒ ▓██ ░▒░ ░▒ ░ ▒ ░▒░ ░ ░ ░ ░ ░▒ ░ ▒░ ░ ░ ░ ░ ▒ ▒ ░░ ░░ ░ ░░ ░ ░ ░░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ */ //focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and //learning something from it #include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define rep(i,a,b) for(ll i=a; i<b; i++) #define per(i,a,b) for(ll i=a; i>=b; i--) #define ll long long int #define ld long double #define vi vector<ll> #define vii vector <pair<ll,ll> > #define sedes set <ll, greater <ll> > #define seasc set <ll> #define pb push_back #define mkp make_pair #define ff first #define ss second constexpr int MOD = 1e9 + 7; #define prec(n) fixed<<setprecision(n) #define maxpq priority_queue<int> #define minpq priority_queue<int, vector<int>, greater<int> > #define umap unordered_map<ll, ll> #define map map<ll, ll> #define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++) #define mems(a, i) memset(a, i, sizeof(a)) #define endl '\n' #define all(v) v.begin(),v.end() #define gcd(a,b) __gcd((a),(b)) #define lcm(a,b) ((a)*(b))/gcd((a),(b)) #define printx(x) printf("%lld\n",x); #define printxy(x,y) cout << x << y <<endl; #define printxyz(x,y,z) cout << x << y << z <<endl; #define deba(a) cout << #a << a << endl; #define debab(a,b) cout << #a << a << #b << b << endl; vi fac(10000000, 1); ll power(ll a, ll n) { ll res = 1; while (n > 0) { if (n % 2 == 0) a = ((a % MOD) * (a % MOD)) % MOD, n /= 2; else res = ((res % MOD) * (a % MOD)) % MOD , n--; } return res % MOD; } ll C(ll n , ll k) { if (k > n) return 0; ll res = F[n]; res = (res * power(F[k], MOD - 2)) % MOD; //inverse of K = power(F[k],MOD-2) res = (res * power(F[n - k], MOD - 2)) % MOD; //inverse of N-K = power(F[N-K],MOD-2) return res % MOD; } int main() { fast; ll n, m, a, b; cin >> n >> m >> a >> b; rep(i, 1, n + m + 1) fac[i] = ((i * fac[i - 1]) % MOD) % MOD; ll ans = 0; for (int i = b; i < m; i++) { ll x = n - a - 1; ll y = i; ll x2 = a - 1; ll y2 = m - i - 1; ll p = (C(x + y, x) % MOD * C(x2 + y2, x2) % MOD) % MOD; ans = (ans + p) % MOD; } cout << ans % MOD << endl; return 0; }
a.cc: In function 'long long int C(long long int, long long int)': a.cc:63:18: error: 'F' was not declared in this scope 63 | ll res = F[n]; | ^
s328016060
p04046
C++
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int mod = 1e9+7; int h, w, a, b; cin >> h >> w >> a >> b; vector<vector<ll>> dp(h, vector<ll>(w)); dp[0][0] = (a < h ? 1ll : 0); for(int i=0; i<h; i++){ for(int j=0; j<w; j++){ if(i||j) dp[i][j] = (h-i<=a && j<b? 0ll: ((i? dp[i-1][j]: 0ll) + (j? dp[i][j-1]: 0ll))%mod); } } cout << dp[h-1][w-1] << '\n'; return 0; }
a.cc: In function 'int main()': a.cc:12:23: error: 'll' was not declared in this scope 12 | vector<vector<ll>> dp(h, vector<ll>(w)); | ^~ a.cc:12:23: error: template argument 1 is invalid a.cc:12:23: error: template argument 2 is invalid a.cc:12:25: error: template argument 1 is invalid 12 | vector<vector<ll>> dp(h, vector<ll>(w)); | ^~ a.cc:12:25: error: template argument 2 is invalid a.cc:12:43: error: template argument 2 is invalid 12 | vector<vector<ll>> dp(h, vector<ll>(w)); | ^ a.cc:12:47: error: expression list treated as compound expression in initializer [-fpermissive] 12 | vector<vector<ll>> dp(h, vector<ll>(w)); | ^ a.cc:13:11: error: invalid types 'int[int]' for array subscript 13 | dp[0][0] = (a < h ? 1ll : 0); | ^ a.cc:17:35: error: invalid types 'int[int]' for array subscript 17 | dp[i][j] = (h-i<=a && j<b? 0ll: ((i? dp[i-1][j]: 0ll) + (j? dp[i][j-1]: 0ll))%mod); | ^ a.cc:17:72: error: invalid types 'int[int]' for array subscript 17 | dp[i][j] = (h-i<=a && j<b? 0ll: ((i? dp[i-1][j]: 0ll) + (j? dp[i][j-1]: 0ll))%mod); | ^ a.cc:17:95: error: invalid types 'int[int]' for array subscript 17 | dp[i][j] = (h-i<=a && j<b? 0ll: ((i? dp[i-1][j]: 0ll) + (j? dp[i][j-1]: 0ll))%mod); | ^ a.cc:20:19: error: invalid types 'int[int]' for array subscript 20 | cout << dp[h-1][w-1] << '\n'; | ^
s530649646
p04046
C
#include <bits/stdc++.h> using namespace std; long long MOD = 1000000007; long long modpow(long long x, long long y, long long n) { long long res = 1; x%=n; while (y>0) { if (y%2==1) { res*=x; res%=n; } y/=2; x*=x; x%=n; } return res; } int main() { vector<long long> facts(200001), invs(200001); facts[0] = 1; invs[0] = 1; for (long long i=1; i<=200000; i++) { facts[i] = facts[i-1]*i%MOD; invs[i] = modpow(facts[i],MOD-2,MOD); } long long h, w, a, b; cin >> h >> w >> a >> b; long long res = 0; long long mult = 1; for (long long i=0; i<h-a; i++) { mult = facts[b-1+i]*invs[i]%MOD; mult*=invs[b-1]; mult%=MOD; mult*=facts[h-i+w-b-2]; mult%=MOD; mult*=invs[h-1-i]; mult%=MOD; mult*=invs[w-b-1]; mult%=MOD; res+=mult; } cout << res; return 0; }
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory 1 | #include <bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s888905605
p04046
C++
#include<bits/stdc++.h> using namespace std; typedef pair<int,int> ii; typedef vector<int> vi; typedef long long ll; #define rep(i,l,r) for(int i=l;i<=r;i++) #define REP(i,l,r) for(int i=l;i>=r;i--) #define fi first #define se second #define eb emplace_back #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define int ll const int mod = 1e9+7 ; int n,m,a,b; int fft[200007], fft_sz = 1; int fact(const int& n){ for(n > fft_sz; ++fft_sz) fft[fft_sz+1] = (fft[fft_sz]*(fft_sz+1)) % mod; return fft[n]; } int mul (const int& a, const int& b){ return a * b %mod; } int mi(const int& a, const int& b){ int ans = (a-b) % mod; return (ans < 0 ? ans + mod : ans); } int binpow(int a, int b){ int res = 1; while(b){ if (b & 1) res = mul(res,a); a = mul(a,a), b >>= 1; } return res; } int divide(const int& a, const int& b){ assert(b > 0); return mul(a,binpow(b,mod-2)); } int c(const int& a, const int& b){ assert(b >= a); return divide(fact(b), mul(fact(a), fact(b-a))); } int path0(const int& n, const int& m){ return c(n-1, n+m-2); } int path(const int& r, const int& c, const int& row, const int& col){ return path0(row-r+1, col-c+1); } signed main() { fastio ; fft[0] = fft[1] = 1LL; cin >> n >> m >> a >> b; int ans = path0(n,m); for(int i = 0, r = n, c = b; i < a; ++i, --r){ ans = mi(ans, mul(path(1,1 ,r,c), path(r,c+1, n,m))); } cout << (ans % mod) << endl; }
a.cc: In function 'll fact(const ll&)': a.cc:20:33: error: expected ';' before ')' token 20 | for(n > fft_sz; ++fft_sz) fft[fft_sz+1] = (fft[fft_sz]*(fft_sz+1)) % mod; | ^ | ;
s560416745
p04046
C++
#include <iostream> using namespace std; #define mod 1000000007 long long fact[1000005]; fact[0] = 1; void precompute() { for (int i = 1; i < 1000000; i++) { fact[i] = (i * (fact[i - 1] % mod)) % mod; } } long long power(int x, int y, int m) { if (y == 0) return 1; long long p = (power(x, y / 2, m) % m); p = ((p % m) * (p % m)) % m; if (y % 2 == 0) return p; else return ((x % m) * (p % m)) % m; } long long modinv(long long int x) { return power(x, m - 2, m); } int main() { long long h, w, a, b; precompute(); cin >> h >> w >> a >> b; long long result = 0; for (int i = 0; i <= w - b - 1; i++) { long long temp1 = ((fact[h - a + b + i - 1]) * modinv(fact[b + i]) % mod * modinv(fact[h - a - 1]) % mod) % mod; long long temp2 = ((fact[w - b - i + a - 2]) * modinv(fact[w - b - 1 - i]) % mod * modinv(fact[a - 1]) % mod) % mod; long long temp += ((temp1 % mod) * (temp2 % mod)) % mod; result = ((result % mod) + (temp % mod)) % mod; } cout << result % mod << endl; return 0; }
a.cc:8:1: error: 'fact' does not name a type 8 | fact[0] = 1; | ^~~~ a.cc: In function 'long long int modinv(long long int)': a.cc:28:25: error: 'm' was not declared in this scope 28 | return power(x, m - 2, m); | ^ a.cc: In function 'int main()': a.cc:39:32: error: expected initializer before '+=' token 39 | long long temp += ((temp1 % mod) * (temp2 % mod)) % mod; | ^~ a.cc:40:37: error: 'temp' was not declared in this scope; did you mean 'temp2'? 40 | result = ((result % mod) + (temp % mod)) % mod; | ^~~~ | temp2
s428446262
p04046
C++
#include <iostream> using namespace std; long long npaths(int rows, int cols) { if (rows == 1 || cols == 1) { return 1; } return ((npaths(rows - 1, cols) % 1000000007) + (npaths(rows, cols - 1) % 1000000007)) % 1000000007 << endl; } int main() { long long h, w, a, b; cin >> h >> w >> a >> b; cout << ((npaths(h, w) % 1000000007) - (npaths(a, b) % 1000000007)) % 1000000007 << endl; return 0; }
a.cc: In function 'long long int npaths(int, int)': a.cc:9:109: error: invalid operands of types 'long long int' and '<unresolved overloaded function type>' to binary 'operator<<' 9 | return ((npaths(rows - 1, cols) % 1000000007) + (npaths(rows, cols - 1) % 1000000007)) % 1000000007 << endl; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
s311857992
p04046
C++
include <bits/stdc++.h> using namespace std; using ll = long long; const int MOD = 1e9 + 7; const int MAXN = 1e6 + 5; ll modpow(ll a, ll b) { ll res = 1; while (b) { if (b&1) res = (res * a) % MOD; a = (a * a) % MOD; b >>= 1; } return res; } ll f[MAXN]; ll invf[MAXN]; ll ncr(ll n, ll r) { if (r == 0 || n == r) return 1; return (((f[n] * invf[n-r]) % MOD) * invf[r]) % MOD; } int main() { int h, w, a, b; cin >> h >> w >> a >> b; f[0] = 1; for (int i = 1; i < MAXN; i++) { f[i] = (f[i-1] * i) % MOD; invf[i] = modpow(f[i], MOD-2); } ll res = 0; for (int i = b; i < w; i++) { int y1 = h - a - 1, x1 = i; int y2 = a - 1, x2 = w - i - 1; ll p = (ncr(x1 + y1, x1) * ncr(x2 + y2, x2)) % MOD; res = (res + p) % MOD; } cout << res << '\n'; }
a.cc:1:1: error: 'include' does not name a type 1 | include <bits/stdc++.h> | ^~~~~~~ a.cc: In function 'int main()': a.cc:29:3: error: 'cin' was not declared in this scope 29 | cin >> h >> w >> a >> b; | ^~~ a.cc:42:3: error: 'cout' was not declared in this scope 42 | cout << res << '\n'; | ^~~~
s533074168
p04046
C++
#include <stdio.h> int H,W,A,B; int res; bool grid[100001][100001]; void recurse(int row,int col) { //base case 1 if (row==H && col==W) { res++; break; } //base case 2 if (grid[row][col]==false) break; //recursive calls else { if (grid[row+1][col]==true && grid[row+1][col]<=H) recurse(row+1,col); if (grid[row][col+1]==true && grid[row][col+1]<=W) recurse(row,col+1); } } int main() { scanf("%d %d %d %d",&H,&W,&A,&B); for (int i=1;i<=H;i++) { for (int j=1;j<=W;j++) { grid[i][j] = true; } } for (int i=H;i>=H-A;i--) { for (int j=W;j>=W-B;j--) { grid[i][j] = false; } } recurse(1,1) printf("%d",res); }
a.cc: In function 'void recurse(int, int)': a.cc:12:17: error: break statement not within loop or switch 12 | break; | ^~~~~ a.cc:17:17: error: break statement not within loop or switch 17 | break; | ^~~~~ a.cc: In function 'int main()': a.cc:48:21: error: expected ';' before 'printf' 48 | recurse(1,1) | ^ | ; 49 | 50 | printf("%d",res); | ~~~~~~
s516927607
p04046
Java
import java.util.Scanner; class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); long h = Integer.parseInt(sc.next()); long w = Integer.parseInt(sc.next()); long a = Integer.parseInt(sc.next()); long b = Integer.parseInt(sc.next()); long mod = 1000000007l; long[] factorialArray = new long[(int)h+w]; factorialArray[0] = 1l; for(long i=1l; i<h+w; i++){ factorialArray[(int)i] *= i%mod*factorialArray[(int)i-1]%mod; } long total = 0l; for(long i=b; i<w; i++){ total += comb(i+h-a-1l, i, factorialArray, mod)*comb(-i+w-2l+a, a-1l, factorialArray, mod); total %= mod; } System.out.println(total); } private static long power(long n, long pow, long mod){ if(pow == 0l){ return 1l; }else if(pow == 1l){ return n; }else{ if(pow%2 == 0l){ return power(n, pow/2l, mod)*power(n, pow/2l, mod)%mod; }else{ return power(n, pow/2l, mod)*power(n, pow/2l, mod)%mod*n%mod; } } } private static long comb(long n, long k, long[] array, long mod){ return array[(int)n]/power(array[(int)k], mod-2l, mod)%mod/power(array[(int)(n-k)], mod-2l, mod)%mod; } }
Main.java:12: error: incompatible types: possible lossy conversion from long to int long[] factorialArray = new long[(int)h+w]; ^ 1 error
s156813078
p04046
Java
import java.util.Scanner; class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); long h = Integer.parseInt(sc.next()); long w = Integer.parseInt(sc.next()); long a = Integer.parseInt(sc.next()); long b = Integer.parseInt(sc.next()); long mod = 1000000007l; long[] factorialArray = new long[h+w]; factorialArray[0] = 1l; for(long i=1l; i<h+w; i++){ factorialArray[i] *= i%mod*factorialArray[i-1l]%mod; } long total = 0l; for(long i=b; i<w; i++){ total += comb(i+h-a-1l, i, factorialArray, mod)*comb(-i+w-2l+a, a-1l, factorialArray, mod); total %= mod; } System.out.println(total); } private static long power(long n, long pow, long mod){ if(pow == 0l){ return 1l; }else if(pow == 1l){ return n; }else{ if(pow%2 == 0l){ return power(n, pow/2l, mod)*power(n, pow/2l, mod)%mod; }else{ return power(n, pow/2l, mod)*power(n, pow/2l, mod)%mod*n%mod; } } } private static long comb(long n, long k, long[] array, long mod){ return array[n]/power(array[k], mod-2l, mod)%mod/power(array[n-k], mod-2l, mod)%mod; } }
Main.java:12: error: incompatible types: possible lossy conversion from long to int long[] factorialArray = new long[h+w]; ^ Main.java:15: error: incompatible types: possible lossy conversion from long to int factorialArray[i] *= i%mod*factorialArray[i-1l]%mod; ^ Main.java:15: error: incompatible types: possible lossy conversion from long to int factorialArray[i] *= i%mod*factorialArray[i-1l]%mod; ^ Main.java:41: error: incompatible types: possible lossy conversion from long to int return array[n]/power(array[k], mod-2l, mod)%mod/power(array[n-k], mod-2l, mod)%mod; ^ Main.java:41: error: incompatible types: possible lossy conversion from long to int return array[n]/power(array[k], mod-2l, mod)%mod/power(array[n-k], mod-2l, mod)%mod; ^ Main.java:41: error: incompatible types: possible lossy conversion from long to int return array[n]/power(array[k], mod-2l, mod)%mod/power(array[n-k], mod-2l, mod)%mod; ^ 6 errors
s479424187
p04046
Java
import java.util.Scanner; class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); long h = Integer.parseInt(sc.next()); long w = Integer.parseInt(sc.next()); long a = Integer.parseInt(sc.next()); long b = Integer.parseInt(sc.next()); long mod = 1000000007l; long total = 0l; for(long i=b; i<w; i++){ total += factorial(i+h-a-1l, i, mod)*power(factorial(h-a-1l, 1l, mod), mod-2l, mod)%mod *factorial(-i+w-2l+a, a-1l, mod)*power(factorial(w-1l-i, 1l, mod), mod-2l, mod)%mod; System.out.println(total); } private static long power(long n, long pow, long mod){ long now_pow = 1l; long now = n%mod; long save = 1l; while(true){ if(pow == 1l){ return save*now%mod; }else if(now_pow*2l < pow){ now *= now; now %= mod; now_pow *= 2l; }else if(now_pow*2l == pow){ now *= now; now %= mod; return save*now%mod; }else{ save *= now; save %= mod; now = n; now %= mod; pow -= now_pow; now_pow = 1l; } } } private static long factorial(long start, long stop, long mod){ long r = 1l; for(long i=start; stop<i; i--){ r *= i%mod; r %= mod; } return r; } }
Main.java:20: error: illegal start of expression private static long power(long n, long pow, long mod){ ^ 1 error
s352085136
p04046
Java
import java.util.Scanner; class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); long h = Integer.parseInt(sc.next()); long w = Integer.parseInt(sc.next()); long a = Integer.parseInt(sc.next()); long b = Integer.parseInt(sc.next()); long mod = 1000000007l; long total = factorial(h+w-2l, h-1l, mod)*power(factorial(w-1l, 1l, mod), mod-2l, mod); long fbd = 0l; for(long i=h-a; i<=h-1l; i++){ fbd -= factorial(i+b-1l, i, mod)*power(factorial(b-1l, 1l, mod), mod-2l, mod)%mod*factorial(w-b+h-i-1l, w-b, mod)*power(factorial(h-i-1l, 1l, mod), mod-2l, mod)%mod; fbd %= mod; } if(total+fbd < 0){ fbd += mod; } System.out.println(total+fbd); } private static long power(long n, long pow, long mod){ long now_pow = 1l; long now = n%mod; long save = 1l; while(true){ if(pow == 1l){ return save*now%mod; }else if(now_pow*2l < pow){ now *= now; now %= mod; now_pow *= 2l; }else if(now_pow*2l == pow){ now *= now; now %= mod; return save*now%mod; }else{ save *= now; save %= mod; now = n; now %= mod; pow -= now_pow; now_pow = 1l; } } } private static long factorial(long start, long stop, long mod){ long r = 1l; for(long i=start; stop<=i; i--){ r *= i%mod; r %= mod; } return r; }
Main.java:58: error: reached end of file while parsing } ^ 1 error
s237537415
p04046
Java
import java.util.Scanner; class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int h = Integer.parseInt(sc.next()); int w = Integer.parseInt(sc.next()); int a = Integer.parseInt(sc.next()); int b = Integer.parseInt(sc.next()); int modnum = 1000000007; int total = modFactorial(h-w-2, h-1)*modFactorial(h-w-2, w-1)/modFactorial(h-w-2, 1)%modnum; for(int i=h-a; i<h; i++){ int f = modFactorial(i+b-1, h-a)*modFactorial(i+b-1,b-1)/modFactorial(i+b-a, 1)%modnum *modFactorial(h-i-1+w-b, h-i-1)*modFactorial(h-i-1+w-b, w-b)/modFactorial(h-i-1+w-b, 1)%modnum; total -= f; } System.out.println(total); } private static int modFactorial(int n, int stop){ int = r for(int i=stop; i<=n; i++){ r *= i%1000000007; } return r; } }
Main.java:23: error: not a statement int = r ^ Main.java:23: error: ';' expected int = r ^ Main.java:23: error: not a statement int = r ^ Main.java:23: error: ';' expected int = r ^ 4 errors
s642305298
p04046
Java
import java.util.Scanner; class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int h = Integer.parseInt(sc.next()); int w = Integer.parseInt(sc.next()); int a = Integer.parseInt(sc.next()); int b = Integer.parseInt(sc.next()); int modnum = 1000000007; int total = modFactorial(h-w-2, h-1)*modFactorial(h-w-2, w-1)/modFactorial(h-w-2)%modnum; for(int i=h-a; i<h; i++){ int f = modFactorial(i+b-1, h-a)*modFactorial(i+b-1,b-1)/modFactorial(i+b-a, 1)%modnum *modFactorial(h-i-1+w-b, h-i-1)*modFactorial(h-i-1+w-b, w-b)/modFactorial(h-i-1+w-b, 1)%modnum; total -= f; } System.out.println(total); } private static int modFactorial(int n, int stop){ if(n == 1){ return 1; }else if(n == stop+1){ return n%1000000007; }else{ return modFactorial(n-1, 1)*(n%1000000007); } } }
Main.java:12: error: method modFactorial in class Main cannot be applied to given types; int total = modFactorial(h-w-2, h-1)*modFactorial(h-w-2, w-1)/modFactorial(h-w-2)%modnum; ^ required: int,int found: int reason: actual and formal argument lists differ in length 1 error
s947842844
p04046
Java
import java.util.Scanner; class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int h = Integer.parseInt(sc.next()); int w = Integer.parseInt(sc.next()); int a = Integer.parseInt(sc.next()); int b = Integer.parseInt(sc.next()); int modnum = 1000000007; int r = modFactorial(h-a+b, h-a)%modnum*modFactorial(h-a+b, b)%modnum/modFactorial(h-a+b, 1); r = r*modFactorial(w+a-b, a)%modnum*modFactorial(w+a-b, w-b)%modnum/modFactorial(w+a-b); System.out.println(r); } private static int modFactorial(int n, int stop){ if(n == 1){ return 1; }else if(n == stop+1){ return n%1000000007; }else{ return modFactorial(n-1)*(n%1000000007); } } }
Main.java:13: error: method modFactorial in class Main cannot be applied to given types; r = r*modFactorial(w+a-b, a)%modnum*modFactorial(w+a-b, w-b)%modnum/modFactorial(w+a-b); ^ required: int,int found: int reason: actual and formal argument lists differ in length Main.java:24: error: method modFactorial in class Main cannot be applied to given types; return modFactorial(n-1)*(n%1000000007); ^ required: int,int found: int reason: actual and formal argument lists differ in length 2 errors
s041430433
p04046
Java
import java.util.Scanner; class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int h = Integer.parseInt(sc.next()); int w = Integer.parseInt(sc.next()); int a = Integer.parseInt(sc.next()); int b = Integer.parseInt(sc.next()); int modnum = 1000000007; int r = modFactorial(h-a+b, h-a)%modnum*modfactorial(h-a+b, b)%modnum/modFactorial(h-a+b, 1); r = r*modFactorial(w+a-b, a)%modnum*modFactorial(w+a-b, w-b)%modnum/modFactorial(w+a-b); System.out.println(r); } private static int modFactorial(int n, int stop){ if(n == 1){ return 1; }else if(n == stop+1){ return n%1000000007; }else{ return modFactorial(n-1)*(n%1000000007); } } }
Main.java:12: error: cannot find symbol int r = modFactorial(h-a+b, h-a)%modnum*modfactorial(h-a+b, b)%modnum/modFactorial(h-a+b, 1); ^ symbol: method modfactorial(int,int) location: class Main Main.java:13: error: method modFactorial in class Main cannot be applied to given types; r = r*modFactorial(w+a-b, a)%modnum*modFactorial(w+a-b, w-b)%modnum/modFactorial(w+a-b); ^ required: int,int found: int reason: actual and formal argument lists differ in length Main.java:24: error: method modFactorial in class Main cannot be applied to given types; return modFactorial(n-1)*(n%1000000007); ^ required: int,int found: int reason: actual and formal argument lists differ in length 3 errors
s559197608
p04046
Java
import java.util.Scanner; class Main{ public static void main(String[] args){ Scanner sc = new Scanner(); int h = Integer.parseInt(sc.next()); int w = Integer.parseInt(sc.next()); int a = Integer.parseInt(sc.next()); int b = Integer.parseInt(sc.next()); int modnum = 1000000007; int r = modFactorial(h-a+b, h-a)%modnum*modfactorial(h-a+b, b)%modnum/modFactorial(h-a+b, 1); r = r*modFactorial(w+a-b, a)%modnum*modFactorial(w+a-b, w-b)%modnum/modFactorial(w+a-b); System.out.println(r); } private static int modFactorial(int n, int stop){ if(n == 1){ return 1; }else if(n == stop+1){ return n%1000000007; }else{ return modFactorial(n-1)*(n%1000000007); } } }
Main.java:5: error: no suitable constructor found for Scanner(no arguments) Scanner sc = new Scanner(); ^ constructor Scanner.Scanner(Readable,Pattern) is not applicable (actual and formal argument lists differ in length) constructor Scanner.Scanner(Readable) is not applicable (actual and formal argument lists differ in length) constructor Scanner.Scanner(InputStream) is not applicable (actual and formal argument lists differ in length) constructor Scanner.Scanner(InputStream,String) is not applicable (actual and formal argument lists differ in length) constructor Scanner.Scanner(InputStream,Charset) is not applicable (actual and formal argument lists differ in length) constructor Scanner.Scanner(File) is not applicable (actual and formal argument lists differ in length) constructor Scanner.Scanner(File,String) is not applicable (actual and formal argument lists differ in length) constructor Scanner.Scanner(File,Charset) is not applicable (actual and formal argument lists differ in length) constructor Scanner.Scanner(File,CharsetDecoder) is not applicable (actual and formal argument lists differ in length) constructor Scanner.Scanner(Path) is not applicable (actual and formal argument lists differ in length) constructor Scanner.Scanner(Path,String) is not applicable (actual and formal argument lists differ in length) constructor Scanner.Scanner(Path,Charset) is not applicable (actual and formal argument lists differ in length) constructor Scanner.Scanner(String) is not applicable (actual and formal argument lists differ in length) constructor Scanner.Scanner(ReadableByteChannel) is not applicable (actual and formal argument lists differ in length) constructor Scanner.Scanner(ReadableByteChannel,String) is not applicable (actual and formal argument lists differ in length) constructor Scanner.Scanner(ReadableByteChannel,Charset) is not applicable (actual and formal argument lists differ in length) Main.java:12: error: cannot find symbol int r = modFactorial(h-a+b, h-a)%modnum*modfactorial(h-a+b, b)%modnum/modFactorial(h-a+b, 1); ^ symbol: method modfactorial(int,int) location: class Main Main.java:13: error: method modFactorial in class Main cannot be applied to given types; r = r*modFactorial(w+a-b, a)%modnum*modFactorial(w+a-b, w-b)%modnum/modFactorial(w+a-b); ^ required: int,int found: int reason: actual and formal argument lists differ in length Main.java:24: error: method modFactorial in class Main cannot be applied to given types; return modFactorial(n-1)*(n%1000000007); ^ required: int,int found: int reason: actual and formal argument lists differ in length 4 errors
s162667250
p04046
Java
import java.util.Scanner; calss Main{ public static void main(String[] args){ Scanner sc = new Scanner(); int h = Integer.parseInt(sc.next()); int w = Integer.parseInt(sc.next()); int a = Integer.parseInt(sc.next()); int b = Integer.parseInt(sc.next()); int modnum = 1000000007; int r = modFactorial(h-a+b, h-a)%modnum*modfactorial(h-a+b, b)%modnum/modFactorial(h-a+b, 1); r = r*modFactorial(w+a-b, a)%modnum*modFactorial(w+a-b, w-b)%modnum/modFactorial(w+a-b); System.out.println(r); } private static int modFactorial(int n, int stop){ if(n == 1){ return 1; }else if(n == stop+1){ return n%1000000007; }else{ return modFactorial(n-1)*(n%1000000007); } }
Main.java:3: error: class, interface, enum, or record expected calss Main{ ^ Main.java:4: error: unnamed classes are a preview feature and are disabled by default. public static void main(String[] args){ ^ (use --enable-preview to enable unnamed classes) 2 errors
s583183617
p04046
C++
// freopen("input.txt", "rt", stdin); // freopen("output.txt", "wt", stdout); #define _GLIBCXX_DEBUG//only for debugging #include <bits/stdc++.h> #include <chrono> #include <ext/rope> #define VALHALLA ios_base::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(13); #define endl "\n" #define pb push_back #define all(v) v.begin(),v.end() #define debug(x) std::cerr << #x << ": " << (x) << '\n'; #define sz(x) (int)x.size() #define fast(map_name) map_name.reserve(1024);map_name.max_load_factor(0.25); using namespace std; using namespace __gnu_cxx; typedef long long int ll; typedef pair<int,int> ii; typedef complex<double> point; const double epsilon=1e-9; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int mod=1e9+7; /* VARIABLE DECLARATION START */ int dp[100001][100001]; int a,b,h,w; /* FUCNTION TEMPLATE STARTS HERE */ double dot(point a,point b){ return (conj(a)*b).real() ; } double cross(point a,point b){ return (conj(a)*b).imag() ; } double dist(point a, point b){ return abs(a-b); } struct neal { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } }; struct HASH{ size_t operator()(const pair<int,int>&x)const{ return (size_t) x.first * 37U + (size_t) x.second; } }; bool isprime(ll n) { if (n == 2 || n == 3) return true; if (n < 2 || n % 2 == 0 || n % 3 == 0) return false; for (ll i = 6; (i - 1) * (i - 1) <= n; i += 6) { if (n % (i - 1) == 0 || n % (i + 1) == 0) { return false; } } return true; } inline ll exp(ll a, ll b, ll mod) { ll n = 1; ll p = a; while (b > 0) { if (b % 2 == 1) { n *= p; n %= mod; } p *= p; p %= mod; b /= 2; } return n; } inline bool comp(double a,double b) { return (fabs(a-b)<epsilon); } ll gcd(ll u, ll v) { ll r; while (0 != v) { r = u % v; u = v; v = r; } return u; } /* FUCNTION TEMPLATE ENDS HERE */ int solve(int r,int c) { if(r>h-a&&r<=h&&c>=1&&c<=b) return 0; if(r==1||c==1)return 1; if(dp[r][c]!=-1)return dp[r][c]; int ans=0; ans=(solve(r-1,c)%mod+solve(r,c-1)%mod)%mod; return dp[r][c]=ans; } int main() { VALHALLA cin>>h>>w; cin>>a>>b; memset(dp,-1,sizeof(dp)); cout<<solve(h,w)<<endl; }
/tmp/cc3zziIu.o: in function `solve(int, int)': a.cc:(.text+0x28a): relocation truncated to fit: R_X86_64_PC32 against symbol `h' defined in .bss section in /tmp/cc3zziIu.o a.cc:(.text+0x290): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/cc3zziIu.o a.cc:(.text+0x29d): relocation truncated to fit: R_X86_64_PC32 against symbol `h' defined in .bss section in /tmp/cc3zziIu.o a.cc:(.text+0x2ae): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/cc3zziIu.o /tmp/cc3zziIu.o: in function `main': a.cc:(.text+0x47b): relocation truncated to fit: R_X86_64_PC32 against symbol `h' defined in .bss section in /tmp/cc3zziIu.o a.cc:(.text+0x497): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/cc3zziIu.o a.cc:(.text+0x4a9): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/cc3zziIu.o a.cc:(.text+0x4c5): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/cc3zziIu.o a.cc:(.text+0x4f7): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/cc3zziIu.o a.cc:(.text+0x4fd): relocation truncated to fit: R_X86_64_PC32 against symbol `h' defined in .bss section in /tmp/cc3zziIu.o collect2: error: ld returned 1 exit status