submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s626881614
p00039
C++
#include<iostream> #include<vector> #include<string> using namespace std; int get_arabic(char x){ if(x=='I')return 1; else if(x=='V')return 5; else if(x=='X')return 10; else if(x=='L')return 50; else if(x=='C')return 100; else if(x=='D')return 500; else if(x=='M')return 1000; } int roma_to_arabic(string roma){ int nums[100]; for(int i=0;i<roma.length();i++){ nums[i]=get_arabic(roma[i]); } for(int i=0;i<roma.length();i+=2){ if(nums[i]>=nums[i+1])nums[i]=nums[i]+nums[i+1]; else if(nums[i]<nums[i+1])nums[i]=nums[i+1]-nums[i]; } int retu=0; for(int i=0;i<roma.length();i+=2){ retu+=nums[i]; } return retu; } int main(){ vector<int> answers; string roma_num; while(cin>>roma_num){ answers.push_back(roma_to_arabic(roma_num)); } for(int i=0;i<answers.size();i++){ cout<<ansers[i]<<endl; } }
a.cc: In function 'int main()': a.cc:39:11: error: 'ansers' was not declared in this scope; did you mean 'answers'? 39 | cout<<ansers[i]<<endl; | ^~~~~~ | answers a.cc: In function 'int get_arabic(char)': a.cc:14:1: warning: control reaches end of non-void function [-Wreturn-type] 14 | } | ^
s397219248
p00039
C++
#include <iostream> #include <queue> using namespace std; ?? ?? int check(char c){ ????if(c == 'I') return 1; ????else if(c == 'V') return 5; ????else if(c == 'X') return 10; ????else if(c == 'L') return 50; ????else if(c == 'C') return 100; ????else if(c == 'D') return 500; ????else if(c == 'M') return 1000; } ?? int main(void){ ????string str; ????while(cin >> str){ ????????int ans = 0; ????????for(int i = 0; i < str.size() - 1; i++){ ????????????if(check(str[i]) >= check(str[i+1])) ans += check(str[i]); ????????????else ans -= check(str[i]); ????????} ????????ans += check(str[str.size() - 1]); ????????cout << ans << endl; ????} ????return 0; }
a.cc:4:1: error: expected unqualified-id before '?' token 4 | ?? | ^ a.cc:15:1: error: expected unqualified-id before '?' token 15 | ?? | ^
s798702605
p00039
C++
#include <iostream> #include <string> using namespace std; int main(void){ char s[104]; int alpha[256]; alpha['\0'] = 0; alpha['I'] = 1; alpha['V'] = 5; alpha['X'] = 10; alpha['L'] = 50; alpha['C'] = 100; alpha['D'] = 500; alpha['M'] = 1000; while(scanf("%s",s) != EOF){ int sum = 0; int len = strlen(s); for(int i=0;i<len;i++){ if(alpha[s[i]] >= alpha[s[i+1]]){ sum += alpha[s[i]]; } else{ sum -= alpha[s[i]]; } } cout<<sum<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:20:27: error: 'strlen' was not declared in this scope 20 | int len = strlen(s); | ^~~~~~ a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include <iostream> +++ |+#include <cstring> 2 | #include <string>
s969992864
p00039
C++
#include <iostream> using namespace std; int main() { int a,m,i; int n[256]; n['I']=1; n['V']=5; n['X']=10; n['L']=50; n['C']=100; n['D']=500; n['M']=1000; char s[128]; while(cin >> s) { for(a=m=0,i=strlen(s)-1; i>=0; i--) { if(n[s[i]]<m) { a-=n[s[i]]; } else { a+=m=n[s[i]]; } } cout << a << endl; } }
a.cc: In function 'int main()': a.cc:19:29: error: 'strlen' was not declared in this scope 19 | for(a=m=0,i=strlen(s)-1; i>=0; i--) | ^~~~~~ a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include <iostream> +++ |+#include <cstring> 2 | using namespace std;
s854790004
p00039
C++
#include <iostream> #include <string> using namespace std; int main() { int a,m,i; int n[256]; n['I']=1; n['V']=5; n['X']=10; n['L']=50; n['C']=100; n['D']=500; n['M']=1000; char s[128]; while(cin >> s) { for(a=m=0,i=strlen(s)-1; i>=0; i--) { if(n[s[i]]<m) { a-=n[s[i]]; } else { a+=m=n[s[i]]; } } cout << a << endl; } }
a.cc: In function 'int main()': a.cc:20:29: error: 'strlen' was not declared in this scope 20 | for(a=m=0,i=strlen(s)-1; i>=0; i--) | ^~~~~~ a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include <iostream> +++ |+#include <cstring> 2 | #include <string>
s689293057
p00039
C++
&#65279;&#65279;#include <iostream> #include <string> using namespace std; int To_num(char); int Calculate(string); int main(void){ string roma; while(cin >> roma) cout << Calculate(roma) << endl; return 0; } int Calculate(string str) { int ans = 0; int now; int next; for(int i = 0 ; i < str.size() ; i++) { now = To_num(str[i]); next = To_num(str[i+1]); if(now >= next) ans += now; else { ans += next - now; i++; } } return ans; } int To_num(char c) /* ツδ債ーツマツ青板篠堋づーツ個サツ催敖づ個青板篠堋づ個表ツ記ツづ可陛渉つヲツづゥ */ { if(c == 'I') return 1; if(c == 'V') return 5; if(c == 'X') return 10; if(c == 'L') return 50; if(c == 'C') return 100; if(c == 'D') return 500; if(c == 'M') return 1000; }
a.cc:1:2: error: stray '#' in program 1 | &#65279;&#65279;#include <iostream> | ^ a.cc:1:10: error: stray '#' in program 1 | &#65279;&#65279;#include <iostream> | ^ a.cc:1:17: error: stray '#' in program 1 | &#65279;&#65279;#include <iostream> | ^ a.cc:1:3: error: expected unqualified-id before numeric constant 1 | &#65279;&#65279;#include <iostream> | ^~~~~ a.cc:1:11: error: expected unqualified-id before numeric constant 1 | &#65279;&#65279;#include <iostream> | ^~~~~ a.cc:1:18: error: 'include' does not name a type 1 | &#65279;&#65279;#include <iostream> | ^~~~~~~ In file included from /usr/include/c++/14/bits/char_traits.h:42, from /usr/include/c++/14/string:42, from a.cc:2: /usr/include/c++/14/bits/postypes.h:68:11: error: 'ptrdiff_t' does not name a type 68 | typedef ptrdiff_t streamsize; // Signed integral type | ^~~~~~~~~ /usr/include/c++/14/bits/postypes.h:41:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 40 | #include <cwchar> // For mbstate_t +++ |+#include <cstddef> 41 | In file included from /usr/include/c++/14/bits/char_traits.h:50: /usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std' 666 | struct is_null_pointer<std::nullptr_t> | ^~~~~~~~~ /usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid 666 | struct is_null_pointer<std::nullptr_t> | ^ /usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid 670 | struct is_null_pointer<const std::nullptr_t> | ^ /usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid 674 | struct is_null_pointer<volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid 678 | struct is_null_pointer<const volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ In file included from /usr/include/wchar.h:35, from /usr/include/c++/14/cwchar:44, from /usr/include/c++/14/bits/postypes.h:40: /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^ /usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1438 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid 1438 | : public integral_constant<std::size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared 1440 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope 1441 | struct rank<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid 1441 | struct rank<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared 2086 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope 2087 | struct remove_extent<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid 2087 | struct remove_extent<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared 2099 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope 2100 | struct remove_all_extents<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid 2100 | struct remove_all_extents<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared 2171 | template<std::size_t _Len> | ^~~ /usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope 2176 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^~~~ /usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^ /usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope 2202 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope 2203 | struct __attribute__((__aligned__((_Align)))) { } __align; | ^~~~~~ /usr/include/c++/14/bits/char_traits.h:144:61: error: 'std::size_t' has not been declared 144 | compare(const char_type* __s1, const char_type* __s2, std::size_t __n); | ^~~ /usr/include/c++/14/bits/char_traits.h:146:40: error: 'size_t' in namespace 'std' does not name a type 146 | static _GLIBCXX14_CONSTEXPR std::size_t | ^~~~~~ /usr/include/c++/14/bits/char_traits.h:150:34: error: 'std::size_t' has not been declared 150 | find(const char_type* __s, std::size_t __n, const char_type& __a); | ^~~ /usr/include/c++/14/bits/char_traits.h:153:52: error: 'std::size_t' has not been declared 153 | move(char_type* __s1, const char_type* __s2, std::size_t __n); | ^~~ /usr/include/c++/14/bits/char_traits.h:156:52: error: 'std::size_t' has not been declared 156 | copy(char_type* __s1, const char_type* __s2, std::size_t __n); | ^~~ /usr/include/c++/14/bits/char_traits.h:159:30: error: 'std::size_t' has not been declared 159 | assign(char_type* __s, std::size_t __n, char_type __a); | ^~~ /usr/include/c++/14/bits/char_traits.h:187:59: error: 'std::size_t' has not been declared 187 | compare(const char_type* __s1, const char_type* __s2, std::size_t __n) | ^~~ /usr/include/c++/14/bits/char_traits.h: In static member function 'static constexpr int __gnu_cxx::char_traits<_CharT>::compare(const char_type*, const char_type*, int)': /usr/include/c++/14/bits/char_traits.h:189:17: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 189 | for (std::size_t __i = 0; __i < __n; ++__i) | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/std
s276796587
p00039
C++
IV CCCCLXXXXVIIII CDXCIX
a.cc:1:1: error: 'IV' does not name a type 1 | IV | ^~
s902979437
p00039
C++
int main() { int a[10], b, c, n; bool judge; cin >> n; REP(i, n) { REP(j, 10) cin >> a[j]; b = 0; c = 0; judge = true; REP(j, 10) { if(a[j] < b && a[j] < c) { judge = false; break; } else if(b < a[j] && c < a[j]) { if(b > c) b = a[j]; else c = a[j]; } else if(b < a[j] && c > a[j]) b = a[j]; else if(b > a[j] && c < a[j]) c = a[j]; else { if(b > c) b = a[j]; else c = a[j]; } } if(judge) cout << "YES" << endl; else cout << "NO" << endl; } }
a.cc: In function 'int main()': a.cc:5:3: error: 'cin' was not declared in this scope 5 | cin >> n; | ^~~ a.cc:6:7: error: 'i' was not declared in this scope 6 | REP(i, n) { | ^ a.cc:6:3: error: 'REP' was not declared in this scope 6 | REP(i, n) { | ^~~
s143999296
p00040
Java
1 y eazqyp pnop pngtg ye obmpngt xmybp mr lygw
Main.java:1: error: class, interface, enum, or record expected 1 ^ 1 error
s880575640
p00040
Java
import java.io.*: import java.util.ArrayList; import java.util.HashMap; class Main{ public static void main(String[] args) throws IOException{ final static int[] alphas={3,5,7,9,11,15,17,19,21,23,25}; final static int[] beta={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25}; BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String line; line=br.readLine(); int n=Integer.parseInt(line); for(int i=0;i<n;i++){ int ga; int gb; line=br.readLine(); String[] str=line.split(" "); char[] chararray=line.toCarArray(); ArrayList<String> array=new ArrayList<String>(); HashMap<Character,Character> dic=new HashMap<Character,Character>(); for(String s : str){ if(s.length()==4){ array.add(s); } } int[] uc=new int[4] loop1: for(String ss : array){ for(int p=0;p<4;p++){ uc[p]=ss.charAt(p); } for(int a=0;a<alphas.length;a++){ for(int b=0;b<beta.length;b++){ char ct=(alphas[a]*('t'-97)+beta[b])%26+97; char ch=(alphas[a]*('h'-97)+beta[b])%26+97; char ci=(alphas[a]*('i'-97)+beta[b])%26+97; char cs=(alphas[a]*('s'-97)+beta[b])%26+97; char ca=beta[b]%26+97; if((uc[0]==ct&&uc[1]==ch&&uc[2]==ci&&uc[3]==cs)||(uc[0]==ct&&uc[1]==ch&&uc[2]==ca&&uc[3]==ct)){ ga=alphas[a]; gb=beta[b]; break loop1; } } } } for(int i=0;i<26;i++){ char nc=(ga*i+gb)%26+97; char c=i+97; dic.put(nc,c); } for(char cc : chararray){ if(cc>='a'&&cc<='z'){ cc=dic.get(cc); } } System.out.println(chararray); } } }
Main.java:1: error: ';' expected import java.io.*: ^ Main.java:26: error: ';' expected int[] uc=new int[4] ^ 2 errors
s923768318
p00040
Java
import java.io.*; import java.util.ArrayList; import java.util.HashMap; class Main{ public static void main(String[] args) throws IOException{ final static int[] alphas={3,5,7,9,11,15,17,19,21,23,25}; final static int[] beta={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25}; BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String line; line=br.readLine(); int n=Integer.parseInt(line); for(int i=0;i<n;i++){ int ga; int gb; line=br.readLine(); String[] str=line.split(" "); char[] chararray=line.toCarArray(); ArrayList<String> array=new ArrayList<String>(); HashMap<Character,Character> dic=new HashMap<Character,Character>(); for(String s : str){ if(s.length()==4){ array.add(s); } } int[] uc=new int[4]; loop1: for(String ss : array){ for(int p=0;p<4;p++){ uc[p]=ss.charAt(p); } for(int a=0;a<alphas.length;a++){ for(int b=0;b<beta.length;b++){ char ct=(alphas[a]*('t'-97)+beta[b])%26+97; char ch=(alphas[a]*('h'-97)+beta[b])%26+97; char ci=(alphas[a]*('i'-97)+beta[b])%26+97; char cs=(alphas[a]*('s'-97)+beta[b])%26+97; char ca=beta[b]%26+97; if((uc[0]==ct&&uc[1]==ch&&uc[2]==ci&&uc[3]==cs)||(uc[0]==ct&&uc[1]==ch&&uc[2]==ca&&uc[3]==ct)){ ga=alphas[a]; gb=beta[b]; break loop1; } } } } for(int i=0;i<26;i++){ char nc=(ga*i+gb)%26+97; char c=i+97; dic.put(nc,c); } for(char cc : chararray){ if(cc>='a'&&cc<='z'){ cc=dic.get(cc); } } System.out.println(chararray); } } }
Main.java:7: error: modifier static not allowed here final static int[] alphas={3,5,7,9,11,15,17,19,21,23,25}; ^ Main.java:8: error: modifier static not allowed here final static int[] beta={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25}; ^ Main.java:18: error: cannot find symbol char[] chararray=line.toCarArray(); ^ symbol: method toCarArray() location: variable line of type String Main.java:33: error: incompatible types: possible lossy conversion from int to char char ct=(alphas[a]*('t'-97)+beta[b])%26+97; ^ Main.java:34: error: incompatible types: possible lossy conversion from int to char char ch=(alphas[a]*('h'-97)+beta[b])%26+97; ^ Main.java:35: error: incompatible types: possible lossy conversion from int to char char ci=(alphas[a]*('i'-97)+beta[b])%26+97; ^ Main.java:36: error: incompatible types: possible lossy conversion from int to char char cs=(alphas[a]*('s'-97)+beta[b])%26+97; ^ Main.java:37: error: incompatible types: possible lossy conversion from int to char char ca=beta[b]%26+97; ^ Main.java:46: error: variable i is already defined in method main(String[]) for(int i=0;i<26;i++){ ^ Main.java:47: error: incompatible types: possible lossy conversion from int to char char nc=(ga*i+gb)%26+97; ^ Main.java:48: error: incompatible types: possible lossy conversion from int to char char c=i+97; ^ 11 errors
s835765324
p00040
Java
import java.io.*; import java.util.ArrayList; import java.util.HashMap; class Main{ public static void main(String[] args) throws IOException{ final int[] alphas={3,5,7,9,11,15,17,19,21,23,25}; final int[] beta={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25}; BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String line; line=br.readLine(); int n=Integer.parseInt(line); for(int i=0;i<n;i++){ int ga; int gb; line=br.readLine(); String[] str=line.split(" "); char[] chararray=line.toCarArray(); ArrayList<String> array=new ArrayList<String>(); HashMap<Character,Character> dic=new HashMap<Character,Character>(); for(String s : str){ if(s.length()==4){ array.add(s); } } int[] uc=new int[4]; loop1: for(String ss : array){ for(int p=0;p<4;p++){ uc[p]=ss.charAt(p); } for(int a=0;a<alphas.length;a++){ for(int b=0;b<beta.length;b++){ char ct=(char)((alphas[a]*('t'-97)+beta[b])%26+97); char ch=(char)((alphas[a]*('h'-97)+beta[b])%26+97); char ci=(char)((alphas[a]*('i'-97)+beta[b])%26+97); char cs=(char)((alphas[a]*('s'-97)+beta[b])%26+97); char ca=(char)(beta[b]%26+97; if((uc[0]==ct&&uc[1]==ch&&uc[2]==ci&&uc[3]==cs)||(uc[0]==ct&&uc[1]==ch&&uc[2]==ca&&uc[3]==ct)){ ga=alphas[a]; gb=beta[b]; break loop1; } } } } for(int i=0;i<26;i++){ char nc=(char)((ga*i+gb)%26+97); char c=(char)(i+97); dic.put(nc,c); } for(char cc : chararray){ if(cc>='a'&&cc<='z'){ cc=dic.get(cc); } } System.out.println(chararray); } } }
Main.java:37: error: ')' expected char ca=(char)(beta[b]%26+97; ^ 1 error
s518162508
p00040
Java
import java.io.*; import java.util.ArrayList; import java.util.HashMap; class Main{ public static void main(String[] args) throws IOException{ final int[] alphas={3,5,7,9,11,15,17,19,21,23,25}; final int[] beta={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25}; BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String line; line=br.readLine(); int n=Integer.parseInt(line); for(int i=0;i<n;i++){ int ga; int gb; line=br.readLine(); String[] str=line.split(" "); char[] chararray=line.toCarArray(); ArrayList<String> array=new ArrayList<String>(); HashMap<Character,Character> dic=new HashMap<Character,Character>(); for(String s : str){ if(s.length()==4){ array.add(s); } } int[] uc=new int[4]; loop1: for(String ss : array){ for(int p=0;p<4;p++){ uc[p]=ss.charAt(p); } for(int a=0;a<alphas.length;a++){ for(int b=0;b<beta.length;b++){ char ct=(char)((alphas[a]*('t'-97)+beta[b])%26+97); char ch=(char)((alphas[a]*('h'-97)+beta[b])%26+97); char ci=(char)((alphas[a]*('i'-97)+beta[b])%26+97); char cs=(char)((alphas[a]*('s'-97)+beta[b])%26+97); char ca=(char)(beta[b]%26+97); if((uc[0]==ct&&uc[1]==ch&&uc[2]==ci&&uc[3]==cs)||(uc[0]==ct&&uc[1]==ch&&uc[2]==ca&&uc[3]==ct)){ ga=alphas[a]; gb=beta[b]; break loop1; } } } } for(int i=0;i<26;i++){ char nc=(char)((ga*i+gb)%26+97); char c=(char)(i+97); dic.put(nc,c); } for(char cc : chararray){ if(cc>='a'&&cc<='z'){ cc=dic.get(cc); } } System.out.println(chararray); } } }
Main.java:18: error: cannot find symbol char[] chararray=line.toCarArray(); ^ symbol: method toCarArray() location: variable line of type String Main.java:46: error: variable i is already defined in method main(String[]) for(int i=0;i<26;i++){ ^ 2 errors
s866247106
p00040
Java
import java.io.*; import java.util.ArrayList; import java.util.HashMap; class Main{ public static void main(String[] args) throws IOException{ final int[] alphas={3,5,7,9,11,15,17,19,21,23,25}; final int[] beta={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25}; BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String line; line=br.readLine(); int n=Integer.parseInt(line); for(int i=0;i<n;i++){ int ga; int gb; line=br.readLine(); String[] str=line.split(" "); char[] chararray=line.toCharArray(); ArrayList<String> array=new ArrayList<String>(); HashMap<Character,Character> dic=new HashMap<Character,Character>(); for(String s : str){ if(s.length()==4){ array.add(s); } } int[] uc=new int[4]; loop1: for(String ss : array){ for(int p=0;p<4;p++){ uc[p]=ss.charAt(p); } for(int a=0;a<alphas.length;a++){ for(int b=0;b<beta.length;b++){ char ct=(char)((alphas[a]*('t'-97)+beta[b])%26+97); char ch=(char)((alphas[a]*('h'-97)+beta[b])%26+97); char ci=(char)((alphas[a]*('i'-97)+beta[b])%26+97); char cs=(char)((alphas[a]*('s'-97)+beta[b])%26+97); char ca=(char)(beta[b]%26+97); if((uc[0]==ct&&uc[1]==ch&&uc[2]==ci&&uc[3]==cs)||(uc[0]==ct&&uc[1]==ch&&uc[2]==ca&&uc[3]==ct)){ ga=alphas[a]; gb=beta[b]; break loop1; } } } } for(int j=0;j<26;j++){ char nc=(char)((ga*j+gb)%26+97); char c=(char)(j+97); dic.put(nc,c); } for(char cc : chararray){ if(cc>='a'&&cc<='z'){ cc=dic.get(cc); } } System.out.println(chararray); } } }
Main.java:47: error: variable ga might not have been initialized char nc=(char)((ga*j+gb)%26+97); ^ Main.java:47: error: variable gb might not have been initialized char nc=(char)((ga*j+gb)%26+97); ^ 2 errors
s256294746
p00040
Java
import java.io.*; import java.util.ArrayList; import java.util.HashMap; class Main{ public static void main(String[] args) throws IOException{ final int[] alphas={1,3,5,7,9,11,15,17,19,21,23,25}; final int[] beta={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25}; BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String line; int n=Integer.parseInt(br.readLine()); for(int i=0;i<n;i++){ int ga=0; int gb=0; line=br.readLine(); String[] str=line.split(" "); char[] chararray=line.toCharArray(); ArrayList<String> array=new ArrayList<String>(); HashMap<Character,Character> dic=new HashMap<Character,Character>(); for(String s : str){ if(s.length()==4){ array.add(s); } } char[] uc=new char[4]; loop1: for(String ss : array){ for(int p=0;p<4;p++){ uc[p]=ss.charAt(p); } for(int a=0;a<alphas.length;a++){ for(int b=0;b<beta.length;b++){ char ct=(char)((alphas[a]*('t'-97)+beta[b])%26+97); char ch=(char)((alphas[a]*('h'-97)+beta[b])%26+97); char ci=(char)((alphas[a]*('i'-97)+beta[b])%26+97); char cs=(char)((alphas[a]*('s'-97)+beta[b])%26+97); char ca=(char)(beta[b]%26+97); if(uc[0]==ct&&uc[1]==ch){ if((uc[2]==ci&&uc[3]==cs)||(uc[2]==ca&&uc[3]==ct)){ ga=alphas[a]; gb=beta[b]; break loop1; } } } } for(int j=0;j<26;j++){ char nc=(char)((ga*j+gb)%26+97); char c=(char)(j+97); dic.put(nc,c); } for(char cc : chararray){ if(cc>='a'&&cc<='z'){ cc=dic.get(cc); } } System.out.println(chararray); } } }
Main.java:59: error: reached end of file while parsing } ^ 1 error
s443367379
p00040
Java
import java.io.*; import java.util.ArrayList; import java.util.HashMap; class Main{ public static void main(String[] args) throws IOException{ final int[] alphas={1,3,5,7,9,11,15,17,19,21,23,25}; final int[] beta={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25}; BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); ArrayList<String> array=new ArrayList<String>(); HashMap<Character,Character> dic=new HashMap<Character,Character>(); int ga; int gb; String line; int n=Integer.parseInt(br.readLine()); while(n-->0){ line=br.readLine(); char[] chararray=line.toCharArray(); for(String s : line.split(" ")){ if(s.length()==4){ array.add(s); } } outside: for(int p=0;p<array.size();p++){ char[] uc=array.get(p).toCharArray(); for(int a=0;a<alphas.length;a++){ for(int b=0;b<beta.length;b++){ char ct=(char)((alphas[a]*('t'-97)+beta[b])%26+97); char ch=(char)((alphas[a]*('h'-97)+beta[b])%26+97); char ci=(char)((alphas[a]*('i'-97)+beta[b])%26+97); char cs=(char)((alphas[a]*('s'-97)+beta[b])%26+97); char ca=(char)((alphas[a]*('a'-97)+beta[b])%26+97); if(uc[0]==ct&&uc[1]==ch){ if((uc[2]==ci&&uc[3]==cs)||(uc[2]==ca&&uc[3]==ct)){ ga=alphas[a]; gb=beta[b]; break outside; } } } } } for(int j=0;j<26;j++){ char nc=(char)((ga*j+gb)%26+97); char c=(char)(j+97); dic.put(nc,c); } for(char cc: chararray){ if(cc>='a'&&cc<='z'){ cc=dic.get(cc); } } System.out.println(chararray); } array.clear(); dic.clear(); } }
Main.java:44: error: variable ga might not have been initialized char nc=(char)((ga*j+gb)%26+97); ^ Main.java:44: error: variable gb might not have been initialized char nc=(char)((ga*j+gb)%26+97); ^ 2 errors
s413783863
p00040
Java
import java.io.*; import java.util.ArrayList; import java.util.HashMap; class Main{ public static void main(String[] args) throws IOException{ final int[] alphas={1,3,5,7,9,11,15,17,19,21,23,25}; final int[] beta={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25}; BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); ArrayList<String> array=new ArrayList<String>(); HashMap<Character,Character> dic=new HashMap<Character,Character>(); int ga=null; int gb=null; String line; int n=Integer.parseInt(br.readLine()); while(n-->0){ line=br.readLine(); char[] chararray=line.toCharArray(); for(String s : line.split(" ")){ if(s.length()==4){ array.add(s); } } outside: for(int p=0;p<array.size();p++){ char[] uc=array.get(p).toCharArray(); for(int a=0;a<alphas.length;a++){ for(int b=0;b<beta.length;b++){ char ct=(char)((alphas[a]*('t'-97)+beta[b])%26+97); char ch=(char)((alphas[a]*('h'-97)+beta[b])%26+97); char ci=(char)((alphas[a]*('i'-97)+beta[b])%26+97); char cs=(char)((alphas[a]*('s'-97)+beta[b])%26+97); char ca=(char)((alphas[a]*('a'-97)+beta[b])%26+97); if(uc[0]==ct&&uc[1]==ch){ if((uc[2]==ci&&uc[3]==cs)||(uc[2]==ca&&uc[3]==ct)){ ga=alphas[a]; gb=beta[b]; break outside; } } } } } for(int j=0;j<26;j++){ char nc=(char)((ga*j+gb)%26+97); char c=(char)(j+97); dic.put(nc,c); } for(char cc: chararray){ if(cc>='a'&&cc<='z'){ cc=dic.get(cc); } } System.out.println(chararray); } array.clear(); dic.clear(); } }
Main.java:12: error: incompatible types: <null> cannot be converted to int int ga=null; ^ Main.java:13: error: incompatible types: <null> cannot be converted to int int gb=null; ^ 2 errors
s555065997
p00040
Java
import java.io.*; import java.util.ArrayList; import java.util.HashMap; class Main{ public static void main(String[] args) throws IOException{ final int[] alphas={1,3,5,7,9,11,15,17,19,21,23,25}; final int[] beta={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25}; BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); ArrayList<String> array=new ArrayList<String>(); HashMap<Character,Character> dic=new HashMap<Character,Character>(); int ga; int gb; String line; int n=Integer.parseInt(br.readLine()); while(n-->0){ ga=o; gb=0; line=br.readLine(); char[] chararray=line.toCharArray(); for(String s : line.split(" ")){ if(s.length()==4){ array.add(s); } } outside: while(true){ for(int p=0;p<array.size();p++){ char[] uc=array.get(p).toCharArray(); for(int a=0;a<alphas.length;a++){ for(int b=0;b<beta.length;b++){ char ct=(char)((alphas[a]*('t'-97)+beta[b])%26+97); char ch=(char)((alphas[a]*('h'-97)+beta[b])%26+97); char ci=(char)((alphas[a]*('i'-97)+beta[b])%26+97); char cs=(char)((alphas[a]*('s'-97)+beta[b])%26+97); char ca=(char)((alphas[a]*('a'-97)+beta[b])%26+97); if(uc[0]==ct&&uc[1]==ch){ if((uc[2]==ci&&uc[3]==cs)||(uc[2]==ca&&uc[3]==ct)){ ga=alphas[a]; gb=beta[b]; break outside; } } } } } } for(int j=0;j<26;j++){ char nc=(char)((ga*j+gb)%26+97); char c=(char)(j+97); dic.put(nc,c); } for(char cc: chararray){ if(cc>='a'&&cc<='z'){ cc=dic.get(cc); } } System.out.println(String.valueOf(chararray)); } array.clear(); dic.clear(); } }
Main.java:17: error: cannot find symbol ga=o; ^ symbol: variable o location: class Main 1 error
s173181501
p00040
Java
import java.io.*; import java.util.ArrayList; import java.util.HashMap; class Main{ public static void main(String[] args) throws IOException{ final int[] alphas={1,3,5,7,9,11,15,17,19,21,23,25}; final int[] betas={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25}; BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); ArrayList<String> array=new ArrayList<String>(); HashMap<Character,Character> dic=new HashMap<Character,Character>(); int ga; int gb; String line; int n=Integer.parseInt(br.readLine()); while(n-->0){ ga=0; gb=0; line=br.readLine(); char[] chararray=line.toCharArray(); for(String s : line.split(" ")){ if(s.length()==4){ array.add(s); } } outside: for(int p=0;p<array.size();p++){ char[] uc=array.get(p).toCharArray(); for(int a=0;a<alphas.length;a++){ for(int b=0;b<betas.length;b++){ char ct=(char)((alphas[a]*('t'-97)+beta[b])%26+97); char ch=(char)((alphas[a]*('h'-97)+beta[b])%26+97); char ci=(char)((alphas[a]*('i'-97)+beta[b])%26+97); char cs=(char)((alphas[a]*('s'-97)+beta[b])%26+97); char ca=(char)((+beta[b])%26+97); if(uc[0]==ct&&uc[1]==ch){ if((uc[2]==ci&&uc[3]==cs)||(uc[2]==ca&&uc[3]==ct)){ ga=alphas[a]; gb=beta[b]; break outside; } } } } } for(int i=0;i<26;i++){ char nc=(char)((ga*i+gb)%26+97); char c=(char)(i+97); dic.put(nc,c); } for(int i=0;i<chararray.length;i++){ if(chararray[i]>='a'&&chararray[i]<='z'){ chararray[i]=dic.get(chararray[i]); } } System.out.println(chararray); array.clear(); dic.clear(); } } }
Main.java:30: error: cannot find symbol char ct=(char)((alphas[a]*('t'-97)+beta[b])%26+97); ^ symbol: variable beta location: class Main Main.java:31: error: cannot find symbol char ch=(char)((alphas[a]*('h'-97)+beta[b])%26+97); ^ symbol: variable beta location: class Main Main.java:32: error: cannot find symbol char ci=(char)((alphas[a]*('i'-97)+beta[b])%26+97); ^ symbol: variable beta location: class Main Main.java:33: error: cannot find symbol char cs=(char)((alphas[a]*('s'-97)+beta[b])%26+97); ^ symbol: variable beta location: class Main Main.java:34: error: cannot find symbol char ca=(char)((+beta[b])%26+97); ^ symbol: variable beta location: class Main Main.java:38: error: cannot find symbol gb=beta[b]; ^ symbol: variable beta location: class Main 6 errors
s381533320
p00040
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class AffineCipher { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); for ( ; n > 0 ; n--) { String cipher = br.readLine(); System.out.println(decrypt(cipher)); } } public static String decrypt(String cipher) { char[] cipherdata = cipher.toCharArray(); char[] decryptdata = new char[cipherdata.length]; for (int a = 0; a < 26; a++) { if (a % 2 == 0 || a % 13 == 0) continue; for (int b = 0; b < 26; b++) { for (int i=0; i < cipherdata.length; i++) { if (cipherdata[i] == ' ') { decryptdata[i] = ' '; } else { decryptdata[i] = f_inverse(cipherdata[i], a, b); } } String decryption = String.valueOf(decryptdata); if (decryption.indexOf("that") != -1 || decryption.indexOf("this") != -1) { return decryption; } } } return "hoge"; } private static char f_inverse(char y, int a, int b) { // y = f(x) = (a * x + b) % 26; y = (char) (y - 'a'); char x; for (x = 0; x < 26; x++) { int fx = (a * x + b) % 26; if (y == fx) break; } return (char) (x + 'a'); } }
Main.java:5: error: class AffineCipher is public, should be declared in a file named AffineCipher.java public class AffineCipher { ^ 1 error
s837680393
p00040
Java
import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.ArrayList;import java.util.List; public class Main { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); List<String> stringDecoded = new ArrayList<String>(); int numLine = Integer.parseInt(br.readLine()); for(int i = 0; i < numLine; i++){ String line = br.readLine(); int[] key = getKey(line); stringDecoded.add(decodeString(line, key[0], key[1])); } for(String str : stringDecoded){ System.out.println(str); } } public static String encodeString(String str, int key1, int key2){ char[] arrayChar = str.toCharArray(); //a〜zならエンコード for(int i = 0; i < arrayChar.length; i++){ if( 0 <= (arrayChar[i] - 'a') && (arrayChar[i] - 'a') <= 25){ int codeEncoded = ((arrayChar[i] - 'a') * key1 + key2) % 26; arrayChar[i] = (char)(codeEncoded + 'a'); } } return String.copyValueOf(arrayChar); } public static String decodeString(String str, int key1, int key2){ char[] arrayChar = str.toCharArray(); //a〜zならデコード for(int i = 0; i < arrayChar.length; i++){ int codeEncoded = arrayChar[i]- 'a' - key2; if(0 <= (arrayChar[i] - 'a') && (arrayChar[i] - 'a') <= 25){ while(codeEncoded % key1 != 0){ codeEncoded += 26; } int codeDecoded = (codeEncoded / key1) % 26; arrayChar[i] = (char)(codeDecoded + 'a'); } } return String.copyValueOf(arrayChar); } public static boolean successDecode(String str, int key1, int key2){ String stringDecoded = decodeString(str, key1, key2); if(stringDecoded.indexOf("that") > -1 || stringDecoded.indexOf("this") > -1){ return true; } else{ return false; } } public static int[] getKey(String str){ int[] key = new int[2]; for(int key1 = 1; key1 <= 25; key1 += 2){ if(key1 == 13) continue; for(int key2 = 0; key2 <= 25; key2++){ if(successDecode(str, key1, key2)){ key[0] = key1; key[1] = key2; return key; } } } return key; }}
Main.java:1: error: reached end of file while parsing import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.ArrayList;import java.util.List; public class Main { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); List<String> stringDecoded = new ArrayList<String>(); int numLine = Integer.parseInt(br.readLine()); for(int i = 0; i < numLine; i++){ String line = br.readLine(); int[] key = getKey(line); stringDecoded.add(decodeString(line, key[0], key[1])); } for(String str : stringDecoded){ System.out.println(str); } } public static String encodeString(String str, int key1, int key2){ char[] arrayChar = str.toCharArray(); //a?z??????? for(int i = 0; i < arrayChar.length; i++){ if( 0 <= (arrayChar[i] - 'a') && (arrayChar[i] - 'a') <= 25){ int codeEncoded = ((arrayChar[i] - 'a') * key1 + key2) % 26; arrayChar[i] = (char)(codeEncoded + 'a'); } } return String.copyValueOf(arrayChar); } public static String decodeString(String str, int key1, int key2){ char[] arrayChar = str.toCharArray(); //a?z?????? for(int i = 0; i < arrayChar.length; i++){ int codeEncoded = arrayChar[i]- 'a' - key2; if(0 <= (arrayChar[i] - 'a') && (arrayChar[i] - 'a') <= 25){ while(codeEncoded % key1 != 0){ codeEncoded += 26; } int codeDecoded = (codeEncoded / key1) % 26; arrayChar[i] = (char)(codeDecoded + 'a'); } } return String.copyValueOf(arrayChar); } public static boolean successDecode(String str, int key1, int key2){ String stringDecoded = decodeString(str, key1, key2); if(stringDecoded.indexOf("that") > -1 || stringDecoded.indexOf("this") > -1){ return true; } else{ return false; } } public static int[] getKey(String str){ int[] key = new int[2]; for(int key1 = 1; key1 <= 25; key1 += 2){ if(key1 == 13) continue; for(int key2 = 0; key2 <= 25; key2++){ if(successDecode(str, key1, key2)){ key[0] = key1; key[1] = key2; return key; } } } return key; }} ^ 1 error
s050511559
p00040
C
#include<stdio.h> char str[258]; int space[257]; int main() { int s, N; int a, b, i, j; char n[4]; int ax[12] = {1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25}; fgets(str, 288, stdin); for (i = 0; str[i] != '\n'; i ++); i --; j = 1; N = 0; for (;i > -1; i --) { N += (str[i] - '0') * j; j *= 10; } for (s = 0; s < N; s ++) { str = {} fgets(str, 258, stdin); j = 0; for (i = 0; str[i] != '\n'; i ++) { if (str[i] == ' ') { space[j] = i; j ++; } } space[++ j] = i; space[++ j] = -1; b = 52; for (a = 0; a < 12; a ++) { for (i = 0; space[i] != -1; i ++) { if (space[i + 1] - space[i] - 1 == 4) { for (j = 0; j < 4; j ++) n[j] = (str[space[i] + j + 1] - 'a') * ax[a] % 26 + 'a'; if (n[1] - n[0] == 'h' - 't' && ((n[2] - n[1] == 'i' - 'h' && n[3] - n[2] == 's' - 'i') || (n[2] - n[1] == 'a' - 'h' && n[3] - n[2] == 't' - 'a'))) { b = 't' - n[0] + 26; break; } } } if (b == 't' - n[0] + 26) break; } for (i = 0; str[i] != '\n'; i ++) if ('a' <= str[i] && str[i] <= 'z') str[i] = ((str[i] - 'a') * ax[a] + b) % 26 + 'a'; printf("%s", str); } return 0; }
main.c: In function 'main': main.c:17:23: error: expected expression before '{' token 17 | str = {} | ^
s050618623
p00040
C
#include<stdio.h> #include<string.h> int main(int argc, const char * argv[]){ char s[257],t[257]; int i,j,k,n,l; scanf("%d\n",&n); for(l=0;l<n;l++){ gets(s); for(i=1;i<=26;i+=2) for(j=0;j<=26;j++){ for(k=0,strcpy(t,s);s[k];k++) if(s[k]>='a'&&s[k]<='z') t[k]=((s[k]-'a')*i+j)%26+'a'; if(strstr(t,"this")||strstr(t,"that")) puts(t); } } return 0; }
main.c: In function 'main': main.c:9:9: error: implicit declaration of function 'gets'; did you mean 'fgets'? [-Wimplicit-function-declaration] 9 | gets(s); | ^~~~ | fgets
s380132449
p00040
C
#include<stdio.h> #include<string.h> int main(int argc, const char * argv[]){ char s[257],t[257]; int i,j,k,n,l; scanf("%d\n",&n); for(l=0;l<n;l++){ gets(s); for(i=1;i<=26;i+=2){ for(j=0;j<=26;j++){ for(k=0,strcpy(t,s);s[k];k++) if(s[k]>='a'&&s[k]<='z') t[k]=((s[k]-'a')*i+j)%26+'a'; if(strstr(t,"this")||strstr(t,"that")) puts(t); } } } return 0; }
main.c: In function 'main': main.c:10:9: error: implicit declaration of function 'gets'; did you mean 'fgets'? [-Wimplicit-function-declaration] 10 | gets(s); | ^~~~ | fgets
s103531187
p00040
C
#include<stdio.h> #include<string.h> int main(int argc, const char * argv[]){ char s[257],t[257]; int i,j,k,n,l; scanf("%d\n",&n); for(l=0;l<n;l++){ gets(s); for(i=1;i<=26;i+=2){ for(j=0;j<=26;j++){ for(k=0,strcpy(t,s);s[k];k++) if(s[k]>='a'&&s[k]<='z') t[k]=((s[k]-'a')*i+j)%26+'a'; if(strstr(t,"this")||strstr(t,"that")) puts(t); } } } return 0; }
main.c: In function 'main': main.c:10:9: error: implicit declaration of function 'gets'; did you mean 'fgets'? [-Wimplicit-function-declaration] 10 | gets(s); | ^~~~ | fgets
s176324709
p00040
C
#include<stdio.h> #include<string.h> int main(int argc, const char * argv[]){ char s[257],t[257]; int i,j,k,n,l; scanf("%d",&n); for(l=0;l<n;l++){ gets(s); for(i=1;i<=26;i+=2){ for(j=0;j<=26;j++){ for(k=0,strcpy(t,s);s[k];k++) if(s[k]>='a'&&s[k]<='z') t[k]=((s[k]-'a')*i+j)%26+'a'; if(strstr(t,"this")||strstr(t,"that")) puts(t); } } } return 0; }
main.c: In function 'main': main.c:10:9: error: implicit declaration of function 'gets'; did you mean 'fgets'? [-Wimplicit-function-declaration] 10 | gets(s); | ^~~~ | fgets
s156180441
p00040
C
#include<stdio.h> #include<string.h> int main(int argc, const char * argv[]){ char s[257],t[257]; int i,j,k,n,l; scanf("%d",&n); for(l=0;l<n+1;l++){ gets(s); for(i=1;i<=26;i+=2){ for(j=0;j<=26;j++){ for(k=0,strcpy(t,s);s[k];k++) if(s[k]>='a'&&s[k]<='z') t[k]=((s[k]-'a')*i+j)%26+'a'; if(strstr(t,"this")||strstr(t,"that")) puts(t); } } } return 0; }
main.c: In function 'main': main.c:10:9: error: implicit declaration of function 'gets'; did you mean 'fgets'? [-Wimplicit-function-declaration] 10 | gets(s); | ^~~~ | fgets
s916277813
p00040
C
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x17): undefined reference to `main' collect2: error: ld returned 1 exit status
s309624593
p00040
C
char s[258],p[258],f[];a,v,i,t,b;main(k){if(~scanf("%*d\n%[^\n]\n"+!k*4,s))for(a=0;++a<27;){for(memset(f,b=i=v=-1,26);++i<26;f[t]=i)v&=f[t=a*i%26];for(;!~v&&++b<26;p[i]=0,strstr(p,"that")|strstr(p,"this")&&main(!puts(p)))for(i=0;s[i];i++)p[i]=s[i]-32?(f[s[i]-97]+b)%26+97:32;}exit(0);}
main.c:1:24: warning: data definition has no type or storage class 1 | char s[258],p[258],f[];a,v,i,t,b;main(k){if(~scanf("%*d\n%[^\n]\n"+!k*4,s))for(a=0;++a<27;){for(memset(f,b=i=v=-1,26);++i<26;f[t]=i)v&=f[t=a*i%26];for(;!~v&&++b<26;p[i]=0,strstr(p,"that")|strstr(p,"this")&&main(!puts(p)))for(i=0;s[i];i++)p[i]=s[i]-32?(f[s[i]-97]+b)%26+97:32;}exit(0);} | ^ main.c:1:24: error: type defaults to 'int' in declaration of 'a' [-Wimplicit-int] main.c:1:26: error: type defaults to 'int' in declaration of 'v' [-Wimplicit-int] 1 | char s[258],p[258],f[];a,v,i,t,b;main(k){if(~scanf("%*d\n%[^\n]\n"+!k*4,s))for(a=0;++a<27;){for(memset(f,b=i=v=-1,26);++i<26;f[t]=i)v&=f[t=a*i%26];for(;!~v&&++b<26;p[i]=0,strstr(p,"that")|strstr(p,"this")&&main(!puts(p)))for(i=0;s[i];i++)p[i]=s[i]-32?(f[s[i]-97]+b)%26+97:32;}exit(0);} | ^ main.c:1:28: error: type defaults to 'int' in declaration of 'i' [-Wimplicit-int] 1 | char s[258],p[258],f[];a,v,i,t,b;main(k){if(~scanf("%*d\n%[^\n]\n"+!k*4,s))for(a=0;++a<27;){for(memset(f,b=i=v=-1,26);++i<26;f[t]=i)v&=f[t=a*i%26];for(;!~v&&++b<26;p[i]=0,strstr(p,"that")|strstr(p,"this")&&main(!puts(p)))for(i=0;s[i];i++)p[i]=s[i]-32?(f[s[i]-97]+b)%26+97:32;}exit(0);} | ^ main.c:1:30: error: type defaults to 'int' in declaration of 't' [-Wimplicit-int] 1 | char s[258],p[258],f[];a,v,i,t,b;main(k){if(~scanf("%*d\n%[^\n]\n"+!k*4,s))for(a=0;++a<27;){for(memset(f,b=i=v=-1,26);++i<26;f[t]=i)v&=f[t=a*i%26];for(;!~v&&++b<26;p[i]=0,strstr(p,"that")|strstr(p,"this")&&main(!puts(p)))for(i=0;s[i];i++)p[i]=s[i]-32?(f[s[i]-97]+b)%26+97:32;}exit(0);} | ^ main.c:1:32: error: type defaults to 'int' in declaration of 'b' [-Wimplicit-int] 1 | char s[258],p[258],f[];a,v,i,t,b;main(k){if(~scanf("%*d\n%[^\n]\n"+!k*4,s))for(a=0;++a<27;){for(memset(f,b=i=v=-1,26);++i<26;f[t]=i)v&=f[t=a*i%26];for(;!~v&&++b<26;p[i]=0,strstr(p,"that")|strstr(p,"this")&&main(!puts(p)))for(i=0;s[i];i++)p[i]=s[i]-32?(f[s[i]-97]+b)%26+97:32;}exit(0);} | ^ main.c:1:34: error: return type defaults to 'int' [-Wimplicit-int] 1 | char s[258],p[258],f[];a,v,i,t,b;main(k){if(~scanf("%*d\n%[^\n]\n"+!k*4,s))for(a=0;++a<27;){for(memset(f,b=i=v=-1,26);++i<26;f[t]=i)v&=f[t=a*i%26];for(;!~v&&++b<26;p[i]=0,strstr(p,"that")|strstr(p,"this")&&main(!puts(p)))for(i=0;s[i];i++)p[i]=s[i]-32?(f[s[i]-97]+b)%26+97:32;}exit(0);} | ^~~~ main.c: In function 'main': main.c:1:34: error: type of 'k' defaults to 'int' [-Wimplicit-int] main.c:1:46: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 1 | char s[258],p[258],f[];a,v,i,t,b;main(k){if(~scanf("%*d\n%[^\n]\n"+!k*4,s))for(a=0;++a<27;){for(memset(f,b=i=v=-1,26);++i<26;f[t]=i)v&=f[t=a*i%26];for(;!~v&&++b<26;p[i]=0,strstr(p,"that")|strstr(p,"this")&&main(!puts(p)))for(i=0;s[i];i++)p[i]=s[i]-32?(f[s[i]-97]+b)%26+97:32;}exit(0);} | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | char s[258],p[258],f[];a,v,i,t,b;main(k){if(~scanf("%*d\n%[^\n]\n"+!k*4,s))for(a=0;++a<27;){for(memset(f,b=i=v=-1,26);++i<26;f[t]=i)v&=f[t=a*i%26];for(;!~v&&++b<26;p[i]=0,strstr(p,"that")|strstr(p,"this")&&main(!puts(p)))for(i=0;s[i];i++)p[i]=s[i]-32?(f[s[i]-97]+b)%26+97:32;}exit(0);} main.c:1:46: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 1 | char s[258],p[258],f[];a,v,i,t,b;main(k){if(~scanf("%*d\n%[^\n]\n"+!k*4,s))for(a=0;++a<27;){for(memset(f,b=i=v=-1,26);++i<26;f[t]=i)v&=f[t=a*i%26];for(;!~v&&++b<26;p[i]=0,strstr(p,"that")|strstr(p,"this")&&main(!puts(p)))for(i=0;s[i];i++)p[i]=s[i]-32?(f[s[i]-97]+b)%26+97:32;}exit(0);} | ^~~~~ main.c:1:46: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:1:97: error: implicit declaration of function 'memset' [-Wimplicit-function-declaration] 1 | char s[258],p[258],f[];a,v,i,t,b;main(k){if(~scanf("%*d\n%[^\n]\n"+!k*4,s))for(a=0;++a<27;){for(memset(f,b=i=v=-1,26);++i<26;f[t]=i)v&=f[t=a*i%26];for(;!~v&&++b<26;p[i]=0,strstr(p,"that")|strstr(p,"this")&&main(!puts(p)))for(i=0;s[i];i++)p[i]=s[i]-32?(f[s[i]-97]+b)%26+97:32;}exit(0);} | ^~~~~~ main.c:1:1: note: include '<string.h>' or provide a declaration of 'memset' +++ |+#include <string.h> 1 | char s[258],p[258],f[];a,v,i,t,b;main(k){if(~scanf("%*d\n%[^\n]\n"+!k*4,s))for(a=0;++a<27;){for(memset(f,b=i=v=-1,26);++i<26;f[t]=i)v&=f[t=a*i%26];for(;!~v&&++b<26;p[i]=0,strstr(p,"that")|strstr(p,"this")&&main(!puts(p)))for(i=0;s[i];i++)p[i]=s[i]-32?(f[s[i]-97]+b)%26+97:32;}exit(0);} main.c:1:97: warning: incompatible implicit declaration of built-in function 'memset' [-Wbuiltin-declaration-mismatch] 1 | char s[258],p[258],f[];a,v,i,t,b;main(k){if(~scanf("%*d\n%[^\n]\n"+!k*4,s))for(a=0;++a<27;){for(memset(f,b=i=v=-1,26);++i<26;f[t]=i)v&=f[t=a*i%26];for(;!~v&&++b<26;p[i]=0,strstr(p,"that")|strstr(p,"this")&&main(!puts(p)))for(i=0;s[i];i++)p[i]=s[i]-32?(f[s[i]-97]+b)%26+97:32;}exit(0);} | ^~~~~~ main.c:1:97: note: include '<string.h>' or provide a declaration of 'memset' main.c:1:172: error: implicit declaration of function 'strstr' [-Wimplicit-function-declaration] 1 | char s[258],p[258],f[];a,v,i,t,b;main(k){if(~scanf("%*d\n%[^\n]\n"+!k*4,s))for(a=0;++a<27;){for(memset(f,b=i=v=-1,26);++i<26;f[t]=i)v&=f[t=a*i%26];for(;!~v&&++b<26;p[i]=0,strstr(p,"that")|strstr(p,"this")&&main(!puts(p)))for(i=0;s[i];i++)p[i]=s[i]-32?(f[s[i]-97]+b)%26+97:32;}exit(0);} | ^~~~~~ main.c:1:172: note: include '<string.h>' or provide a declaration of 'strstr' main.c:1:172: warning: incompatible implicit declaration of built-in function 'strstr' [-Wbuiltin-declaration-mismatch] main.c:1:172: note: include '<string.h>' or provide a declaration of 'strstr' main.c:1:188: error: invalid operands to binary | (have 'char *' and 'char *') 1 | char s[258],p[258],f[];a,v,i,t,b;main(k){if(~scanf("%*d\n%[^\n]\n"+!k*4,s))for(a=0;++a<27;){for(memset(f,b=i=v=-1,26);++i<26;f[t]=i)v&=f[t=a*i%26];for(;!~v&&++b<26;p[i]=0,strstr(p,"that")|strstr(p,"this")&&main(!puts(p)))for(i=0;s[i];i++)p[i]=s[i]-32?(f[s[i]-97]+b)%26+97:32;}exit(0);} | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ | | | | char * char * main.c:1:213: error: implicit declaration of function 'puts' [-Wimplicit-function-declaration] 1 | char s[258],p[258],f[];a,v,i,t,b;main(k){if(~scanf("%*d\n%[^\n]\n"+!k*4,s))for(a=0;++a<27;){for(memset(f,b=i=v=-1,26);++i<26;f[t]=i)v&=f[t=a*i%26];for(;!~v&&++b<26;p[i]=0,strstr(p,"that")|strstr(p,"this")&&main(!puts(p)))for(i=0;s[i];i++)p[i]=s[i]-32?(f[s[i]-97]+b)%26+97:32;}exit(0);} | ^~~~ main.c:1:213: note: include '<stdio.h>' or provide a declaration of 'puts' main.c:1:277: error: implicit declaration of function 'exit' [-Wimplicit-function-declaration] 1 | char s[258],p[258],f[];a,v,i,t,b;main(k){if(~scanf("%*d\n%[^\n]\n"+!k*4,s))for(a=0;++a<27;){for(memset(f,b=i=v=-1,26);++i<26;f[t]=i)v&=f[t=a*i%26];for(;!~v&&++b<26;p[i]=0,strstr(p,"that")|strstr(p,"this")&&main(!puts(p)))for(i=0;s[i];i++)p[i]=s[i]-32?(f[s[i]-97]+b)%26+97:32;}exit(0);} | ^~~~ main.c:1:1: note: include '<stdlib.h>' or provide a declaration of 'exit' +++ |+#include <stdlib.h> 1 | char s[258],p[258],f[];a,v,i,t,b;main(k){if(~scanf("%*d\n%[^\n]\n"+!k*4,s))for(a=0;++a<27;){for(memset(f,b=i=v=-1,26);++i<26;f[t]=i)v&=f[t=a*i%26];for(;!~v&&++b<26;p[i]=0,strstr(p,"that")|strstr(p,"this")&&main(!puts(p)))for(i=0;s[i];i++)p[i]=s[i]-32?(f[s[i]-97]+b)%26+97:32;}exit(0);} main.c:1:277: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch] 1 | char s[258],p[258],f[];a,v,i,t,b;main(k){if(~scanf("%*d\n%[^\n]\n"+!k*4,s))for(a=0;++a<27;){for(memset(f,b=i=v=-1,26);++i<26;f[t]=i)v&=f[t=a*i%26];for(;!~v&&++b<26;p[i]=0,strstr(p,"that")|strstr(p,"this")&&main(!puts(p)))for(i=0;s[i];i++)p[i]=s[i]-32?(f[s[i]-97]+b)%26+97:32;}exit(0);} | ^~~~ main.c:1:277: note: include '<stdlib.h>' or provide a declaration of 'exit' main.c: At top level: main.c:1:20: warning: array 'f' assumed to have one element 1 | char s[258],p[258],f[];a,v,i,t,b;main(k){if(~scanf("%*d\n%[^\n]\n"+!k*4,s))for(a=0;++a<27;){for(memset(f,b=i=v=-1,26);++i<26;f[t]=i)v&=f[t=a*i%26];for(;!~v&&++b<26;p[i]=0,strstr(p,"that")|strstr(p,"this")&&main(!puts(p)))for(i=0;s[i];i++)p[i]=s[i]-
s577063670
p00040
C
/* AizuOnline A0040 Affine Cipher */ #include <stdio.h> #include <string.h> unsigned char ango[257]; unsigned char ango2[257]; #define AZ_dif ('Z'-'A'+1) #define DELIM " .\n" int alpha,beta; int devmod(char x,char y,int m) { int i,s,r; //printf("xym %d %d \n",x,y); for(i=0,s=x;i<m;i++,s+=m) if(((s % y)==0)) { r=s/y; if(r<0)r+=m; //printf("dm%d %d %d\n",x,y,s/y); return(r); } return(0); } int calc_alpha(char c1,char c2,char c3,char c4) { //printf("CA %c %c %c %c\n",c1,c2,c3,c4); return(devmod(c1-c2,c3-c4, AZ_dif)); } main() { int i; char *p; int a1,a2,a3,a21,a31; int n; int loop; scanf("%d ",&n); for(loop=0;loop<n;loop++) { //printf("gyo=%d\n",n); fgets(ango,256,stdin); strcpy(ango2,ango); beta=-99; p=strtok(ango2,DELIM); do { if(strlen(p)!=4) continue; a1=calc_alpha(p[0],p[2],'t','i'); a2=calc_alpha(p[2],p[1],'i','h'); //a3=calc_alpha(p[2],p[3],'i','s'); a21=calc_alpha(p[1],p[2],'h','a'); a31=calc_alpha(p[3],p[2],'t','a'); //printf("a:%d %d %d %d\n",a1,a2,a21,a31); if(a1==a2 && !isloewer(p[4])) { alpha=a1; if((alpha % 2)==0 ||(alpha % 13)==0) continue; beta= ((p[0]-'a')-('t'-'a')*alpha) % AZ_dif; if(beta < 0)beta+=AZ_dif; break; } else if(a21==a31 && !isalpha(p[4])) { alpha=a21; if((alpha % 2)==0 ||(alpha % 13)==0) continue; beta= ((p[0]-'a')-('t'-'a')*alpha) % AZ_dif; if(beta < 0)beta+=AZ_dif; break; } } while(p=strtok(NULL,DELIM)); #ifdef DEBUG printf("ab %d %d\n",alpha,beta); #endif if(beta != -99) { for(i=0;ango[i];i++) if(isalpha(ango[i])) { ango[i] -= 'a'; ango[i] -= beta; ango[i] = devmod(ango[i],alpha,AZ_dif); ango[i] += 'a'; } printf("%s",ango); //printf("%d\n",devmod(255,alpha,AZ_dif)); } } return(0); }
main.c:37:1: error: return type defaults to 'int' [-Wimplicit-int] 37 | main() | ^~~~ main.c: In function 'main': main.c:66:25: error: implicit declaration of function 'isloewer' [-Wimplicit-function-declaration] 66 | if(a1==a2 && !isloewer(p[4])) | ^~~~~~~~ main.c:75:34: error: implicit declaration of function 'isalpha' [-Wimplicit-function-declaration] 75 | else if(a21==a31 && !isalpha(p[4])) | ^~~~~~~ main.c:7:1: note: include '<ctype.h>' or provide a declaration of 'isalpha' 6 | #include <string.h> +++ |+#include <ctype.h> 7 |
s120717458
p00040
C
#include"test.h" int main() { char s[257],t[257]; init(); for(int i=0;i<10;i++) { int a=rand()%10000,b=rand()%10000; gets(s); strcpy(t,s); for(int j=0,k=strlen(s);j<k;j++) if(isalnum(s[j])) t[j]=(a*(s[j]-'a')+b)%26+'a'; printf("%d %d\n",a,b); puts(t); } return 0; }
main.c:1:9: fatal error: test.h: No such file or directory 1 | #include"test.h" | ^~~~~~~~ compilation terminated.
s036671431
p00040
C++
#include<iostream> #include<vector> #include<algorithm> #include<string> #include<cctype> #include<cstdlib> #include<cstdio> #include<cstring> using namespace std; int main(){ int n; cin>>n; string str; getline(cin.str); while(n--){ getline(cin,str); bool f=false; for(int a=1;!f;a++){ if(a%2==0||a%13==0)continue; for(int b=0;!f&&b<26;b++){ char m[26]; for(int i=0;i<26;i++)m[(i*a+b)%26]=i+'a'; string t=str; for(int i=0;i<t.size();i++){ if(islower(t[i]))t[i]=m[t[i]-'a']; } bool f_this=(t.find("this")!=string::npos); bool f_that=(t.find("that")!=string::npos); if(f_this||f_that){ str=t; f=true; } } } cout<<str<<endl; } }
a.cc: In function 'int main()': a.cc:14:17: error: 'std::istream' {aka 'class std::basic_istream<char>'} has no member named 'str' 14 | getline(cin.str); | ^~~
s062313838
p00040
C++
#include <iostream> #include <cstdio> #include <algorithm> #include <cassert> #include <vector> #include <string> #include <cmath> #include <map> #include <sstream> #include <cstdio> using namespace std; const int MAX= 10000100; #define loop(i,a,b) for(int i = a ; i < b ; i ++) #define rep(i,a) loop(i,0,a) #define all(a) (a).begin(),(a).end() #define ll long long int #define gcd(a,b) __gcd(a,b) #define pb(a) push_back(a) int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);} int lcm(int a, int b) {return a*b / gcd(a, b);} int main(void){ int num; cin>>num; cin.ignore(); rep(i,num){ string s,ss; getline(cin,s); bool flag = true; ss = s; rep(i,26){ rep(j,26){ if(ss.find("that") == string::npos & ss.find("this") == string::npos){ rep(k,s.size()){ ss=((((s[i]-'a')*x)+y)%26)+'a'; } }else{ cout<<ss<<endl; flag = false; break; } } if(!flag){ break; } } } }
a.cc: In function 'int main()': a.cc:37:30: error: 'x' was not declared in this scope 37 | ss=((((s[i]-'a')*x)+y)%26)+'a'; | ^ a.cc:37:33: error: 'y' was not declared in this scope 37 | ss=((((s[i]-'a')*x)+y)%26)+'a'; | ^
s857766948
p00040
C++
#include<iostream> #include<vector> #include<string> using namespace std; int main(){ int n=10; cin>>n; string str; n++; while(n--){ getline(cin,str); for(int i=3;i<99;i++){ if(i%2==0||i%13==0)continue; for(int j=0;j<26;j++){ vector<int>vec; for(int k=0;k<26;k++){ vec.push_back((i*k+j)%26); } sort(vec.begin(),vec.end()); if(unique(vec.begin(), vec.end())!=vec.end())continue; string ss=str; for(int k=0;k<str.length();k++){ if(str[k]>='a'&&str[k]<='z') ss[k]=((i*(str[k]-'a')+j)%26)+'a'; else ss[k]=str[k]; } int len=ss.length(); for(int k=0;k<len-3;k++){ if(ss.substr(k,4)=="this"||ss.substr(k,4)=="that"){ cout<<ss<<endl; goto next; } } } } next:; } }
a.cc: In function 'int main()': a.cc:20:17: error: 'sort' was not declared in this scope; did you mean 'short'? 20 | sort(vec.begin(),vec.end()); | ^~~~ | short a.cc:21:20: error: 'unique' was not declared in this scope 21 | if(unique(vec.begin(), vec.end())!=vec.end())continue; | ^~~~~~
s449290203
p00040
C++
#include<iostream> #include<string.h> #include<vector> #include<list> #include<stdio.h> #include<math.h> #include<iomanip> #include<map> #include<stack> #include<queue> #include<algorithm> #define range(i,a,b) for(int i = (a); i < (b); i++) #define rep(i,b) range(i,0,b) #define debug(x) cout << "debug " << x << endl; using namespace std; int a, b; void check(int A[], char inp[]){ int k; rep(i, 1000){ rep(j, 1000){ if((i * A[0] + j) % 26 == inp[0] - 'a'){ for(k = 1; k < 4; k++){ if((i * A[k] + j) % 26 != inp[k] - 'a') break; } } if(k == 4){ a = i; b = j; return; } } } } int main(){ char str[356][356]; char inp[356]; int n,i; int This[4] = {19, 7, 8, 18}, That[4] = {19, 7, 0, 19}; while(cin >> n){ rep(i,n){ len = 0; a = b = -1; for(i = 0; cin >> inp; i++){ strcpy(str[i], inp); if(strlen(inp) == 4){ check(This, inp); if(a == -1) check(That, inp); } } rep(j,i){ rep(k, strlen(str[j])){ rep(l,26){ if((a * l + b) % 26 == str[j][k] - 'a'){ printf("%c",'a' + l); } } } cout << ' '; } cout << endl; } } }
a.cc: In function 'int main()': a.cc:44:13: error: 'len' was not declared in this scope 44 | len = 0; | ^~~
s080043461
p00040
C++
import java.util.HashSet; import java.util.Scanner; import java.util.Set; //Affine Cipher public class AOJ0040 { static long gcd(long a, long b){ if(a < b){ long tmp = a; a = b; b = tmp; } while(b!=0){ long r = a%b; a = b; b = r; } return a; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); sc.nextLine(); Set<String> valid = new HashSet<String>(); for(int a=1;a<=100;a++){ if(gcd(a,26)>1)continue; for(int b=1;b<=100;b++){ boolean f = true; boolean[] c = new boolean[26]; for(int j=0;j<26;j++){ int x = (a*j+b)%26; if(c[x])f=false; c[x] = true; } if(f)valid.add(a+" "+b); } } while(t--!=0){ String[] s = sc.nextLine().split(" "); for(String vv:valid){ String[] v = vv.split(" "); int a = Integer.parseInt(v[0]); int b = Integer.parseInt(v[1]); boolean f = false; StringBuilder sb = new StringBuilder(); boolean head = true; for(String m : s){ if(!head)sb.append(' '); head = false; char[] ch = new char[m.length()]; for(int i=0;i<ch.length;i++)ch[i]=(char)(((m.charAt(i)-'a')*a+b)%26 + 'a'); String x = new String(ch); if(x.equals("that")||x.equals("this"))f=true; sb.append(x); } if(f){ System.out.println(sb); break; } } } } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.util.HashSet; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: 'import' does not name a type 2 | import java.util.Scanner; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: 'import' does not name a type 3 | import java.util.Set; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:6:1: error: expected unqualified-id before 'public' 6 | public class AOJ0040 { | ^~~~~~
s978353358
p00040
C++
#include <bits/stdc++.h> #define rep(i,a) for(int i = 0;i < (a); i++) #define repi(i,a,b) for(int i = (a); i < (b); i++) using namespace std; int n; int main(){ cin >> n; cin.ignore(); while(n--){ vector<string> str; string tmp; getline(cin,tmp); stringstream ss; ss << tmp; while(ss >> tmp) str.pb(tmp); int a = 0, b = 0; rep(i,str.size())if(str[i].size() == 4){ repi(j,3,26*26)if(__gcd(j,26) == 1){ rep(k,26){ string s = "this", t = "that"; rep(u,4){ s[u] = (j * (s[u]-'a') + k) % 26 + 'a'; t[u] = (j * (t[u]-'a') + k) % 26 + 'a'; } if(s == str[i] || t == str[i]){ a = j; b = k; break; } } if(a) break; } if(a) break; } string abc = "abcdefghijklmnopqrstuvwxyz"; rep(i,26) abc[i] = (a * i + b) % 26 + 'a'; rep(i,str.size()){ rep(j,str[i].size()) cout << (char)(abc.find(str[i][j]) + 'a'); cout << (i==str.size()-1? '\n': ' '); } } return 0; }
a.cc: In function 'int main()': a.cc:17:30: error: 'class std::vector<std::__cxx11::basic_string<char> >' has no member named 'pb' 17 | while(ss >> tmp) str.pb(tmp); | ^~
s649157844
p00040
C++
#include<iostream> #include<string> #include<stdio.h> int main(){ string s; int n; cin>>n; for(int u=0;u<n;u++){ getline(cin,s); int a=0; bool t=false; while(true){ int b=0; while(true){ for(int i=0;i<s.size();i++){ if(isalpha(s[i])!=0) s[i]=(a*(s[i]-'a')+b)%26+'a'; } for(int i=0;i<s.size()-3;i++){ if(s[i]=='t'&&s[i+1]=='h'&&s[i+2]=='i'&&s[i+3]=='s'){ t=true; break; } if(s[i]=='t'&&s[i+1]=='h'&&s[i+2]=='a'&&s[i+3]=='t'){ t=true; break; } } b++; } if(t==true) break; a++; } for(int i=0;i<s.size();i++) cout<<s[i]; cout<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:5:2: error: 'string' was not declared in this scope 5 | string s; | ^~~~~~ a.cc:5:2: note: suggested alternatives: In file included from /usr/include/c++/14/iosfwd:41, from /usr/include/c++/14/ios:40, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stringfwd.h:77:33: note: 'std::string' 77 | typedef basic_string<char> string; | ^~~~~~ In file included from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44: /usr/include/c++/14/string:76:11: note: 'std::pmr::string' 76 | using string = basic_string<char>; | ^~~~~~ a.cc:7:2: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 7 | cin>>n; | ^~~ | std::cin /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:9:14: error: 's' was not declared in this scope 9 | getline(cin,s); | ^ a.cc:36:2: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 36 | cout<<s[i]; | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ a.cc:37:2: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 37 | cout<<endl; | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ a.cc:37:8: error: 'endl' was not declared in this scope; did you mean 'std::endl'? 37 | cout<<endl; | ^~~~ | std::endl /usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here 744 | endl(basic_ostream<_CharT, _Traits>& __os) | ^~~~
s586708856
p00040
C++
1 y eazqyp pnop pngtg ye obmpngt xmybp mr lygw
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 1 | ^
s370830802
p00040
C++
#include <iostream> #include <algorithm> #include <string> using namespace std; bool IsCoprime(int a, int b) { while (a > 0 && b > 0) { if (a < b) swap(a, b); a %= b; } if (a == 1 || b == 1) return true; return false; } char get(int a, int b, char c) { for (int i = 0; i < 26; i++) { if ((a * i + b) % 26 == c - 'a') return char(i + 'a'); } } int main() { int n; string cip; string dec; cin >> n; cin.get(); while (n--) { getline(cin, cip); dec = cip; for (int a = 0; a < 26; a++) { if (!IsCoprime(a, 26)) continue; for (int b = 0; b < 26; b++) { for (int i = 0; i < cip.size(); i++) { dec[i] = get(a, b, cip[i]); } if (dec.find("that") != -1 || dec.find("this") != -1) { cout << dec << endl; } } } }  return 0; }
a.cc:58:9: error: stray '\32' in program 58 | <U+001A> | ^~~~~~~~ a.cc: In function 'char get(int, int, char)': a.cc:25:1: warning: control reaches end of non-void function [-Wreturn-type] 25 | } | ^
s211979482
p00040
C++
#include<iostream> #include<map> #include<string> #include<vector> #include<algorithm> #include<numeric> #include<cmath> using namespace std; int inf = 1000000000; char affine(char c, int a, int b){ int x = c - 'a'; int y = ( a * x + b ) % 26; char r = 'a' + y; return r; } int main(){ int n; cin >> n; cin.ignore(); for(int l=0; l<n; l++){ string s; getline(cin, s); for(int i=0; i<50; i++){ if( i %= 2 == 0 || i %= 13 == 0 ) continue; for(int j=0; j<50; j++){ string t = ""; for(int k=0; k<s.size(); k++){ if( 'a' <= s[k] && s[k] <= 'z' ) t += affine(s[k], i, j); else t += s[k]; } for(int k=0; k<t.size()-4; k++){ if( (t[k] == 't' && t[k+1] == 'h' && t[k+2] == 'a' && t[k+3] == 't') || (t[k] == 't' && t[k+1] == 'h' && t[k+2] == 'i' && t[k+3] == 's') ) cout << t << endl; } } } } return 0; }
a.cc: In function 'int main()': a.cc:28:28: warning: division by zero [-Wdiv-by-zero] 28 | if( i %= 2 == 0 || i %= 13 == 0 ) continue; | ~~~~~~~~~~~~^~~~~~~~~~ a.cc:28:23: error: lvalue required as left operand of assignment 28 | if( i %= 2 == 0 || i %= 13 == 0 ) continue; | ~~~~~~~^~~~
s770918652
p00040
C++
#include<stdio.h> #include<string.h> char c[257]; char d[257]; bool use[26]; int main(){ int a; scanf("%d ",&a); while(a--){ gets(c); int t=strlen(c); for(int i=0;i<26;i++){ for(int j=0;j<26;j++){ bool ok=false; for(int k=0;k<26;k++)use[k]=false; for(int k=0;k<26;k++){ if(use[(i*k+j)%26])goto dame; else use[(i*k+j)%26]=true; } for(int k=0;k<t;k++){ if(c[k]<='z'&&c[k]>='a'){ d[k]=(i*(c[k]-'a')+j)%26+'a'; }else{ d[k]=c[k]; } } for(int k=0;k<t-3;k++){ if(d[k]=='t'&&d[k+1]=='h'){ if(d[k+2]=='a'&&d[k+3]=='t')ok=true; if(d[k+2]=='i'&&d[k+3]=='s')ok=true; } } if(ok){ printf("%s\n",d); } dame:; } } } }
a.cc: In function 'int main()': a.cc:10:17: error: 'gets' was not declared in this scope; did you mean 'getw'? 10 | gets(c); | ^~~~ | getw
s366307552
p00040
C++
#include <iostream> #include <cstdio> #include <string> #include <map> using namespace std; char encode(char x,int a,int b){ return ( ( a * (x-'a') + b) % 26 ) + 'a'; } char decode(char x, int a, int b){ int t = ( x - 'a') - b; while( (t%a) != 0 ) t += 26; return (t/a) % 26 + 'a'; } string encode(string s, int a, int b){ for(int i =0 ; i<(int)s.size() ; ++i ) if( s[i] >= 'a' && s[i] <= 'z' ) s[i] = encode( s[i] , a , b ); return s; } string decode(string s, int a, int b){ for(int i =0 ; i<(int)s.size() ; ++i ) if( s[i] >= 'a' && s[i] <= 'z' ) s[i] = decode( s[i] , a , b ); return s; } int main(){ int n=1; int a[12] = {1,3,5,7,9,11,15,17,19,21,23,25}; string str, s; scanf("%d ", &n); for(int i=0 ; i<n ; ++i){ bool flag = false; //getline( cin , str ); char foo[257]; gets( foo ); str = foo; for(int i=0 ; i<12 ; ++i){ for(int j=0 ; j<26 ; j++){ s = decode( str , a[i] , j ); if( s.find("this") != string::npos || s.find("that") != string::npos ){ flag = true; break; } } if( flag ) break; } cout << s << endl; } }
a.cc: In function 'int main()': a.cc:42:17: error: 'gets' was not declared in this scope; did you mean 'getw'? 42 | gets( foo ); | ^~~~ | getw
s915424717
p00040
C++
#include <iostream> #include <cstdio> #include <string> #include <map> using namespace std; char encode(char x,int a,int b){ return ( ( a * (x-'a') + b) % 26 ) + 'a'; } char decode(char x, int a, int b){ int t = ( x - 'a') - b; while( (t%a) != 0 ) t += 26; return (t/a) % 26 + 'a'; } string encode(string s, int a, int b){ for(int i =0 ; i<(int)s.size() ; ++i ) if( s[i] >= 'a' && s[i] <= 'z' ) s[i] = encode( s[i] , a , b ); return s; } string decode(string s, int a, int b){ for(int i =0 ; i<(int)s.size() ; ++i ) if( s[i] >= 'a' && s[i] <= 'z' ) s[i] = decode( s[i] , a , b ); return s; } int main(){ int n=1; int a[12] = {1,3,5,7,9,11,15,17,19,21,23,25}; string str, s; scanf("%d ", &n); for(int i=0 ; i<n ; ++i){ bool flag = false; //getline( cin , str ); char foo[257]; gets( foo ); str = foo; for(int i=0 ; i<12 ; ++i){ for(int j=0 ; j<26 ; j++){ s = decode( str , a[i] , j ); if( s.find("this") != string::npos || s.find("that") != string::npos ){ flag = true; break; } } if( flag ) break; } printf("%s\n" , s.c_str() ); } }
a.cc: In function 'int main()': a.cc:42:17: error: 'gets' was not declared in this scope; did you mean 'getw'? 42 | gets( foo ); | ^~~~ | getw
s627198463
p00040
C++
#include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<cassert> #include<iostream> #include<sstream> #include<string> #include<vector> #include<queue> #include<set> #include<map> #include<utility> #include<numeric> #include<algorithm> #include<bitset> #include<complex> using namespace std; typedef long long Int; typedef vector<int> vint; typedef pair<int,int> pint; #define mp make_pair template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; } template<class T> void chmin(T &t, T f) { if (t > f) t = f; } template<class T> void chmax(T &t, T f) { if (t < f) t = f; } int in() { int x; scanf("%d", &x); return x; } int main() { int i,n; scanf("%d\n",&n); for(i=0;i<n;i++){ string str; char s[300]; gets(s); str=s; //cout<<str<<endl; int a,b; for(a=1;a<26;a+=2){ if(a==13)continue; for(b=0;b<26;b++){ string st=""; int j; for(j=0;j<str.size();j++){ if(isalpha(str[j])){ st+=((str[j]-'a')*a+b)%26+'a'; }else{ st+=str[j]; } } //if(st[0]=='i')cout<<st<<endl; string::size_type index1=st.find("that"); string::size_type index2=st.find("this"); if(index1!=string::npos||index2!=string::npos){ cout<<st<<endl; goto end; } } } end:; } return 0; }
a.cc: In function 'int main()': a.cc:37:17: error: 'gets' was not declared in this scope; did you mean 'getw'? 37 | gets(s); | ^~~~ | getw
s452124501
p00040
C++
#include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<cassert> #include<iostream> #include<sstream> #include<string> #include<vector> #include<queue> #include<set> #include<map> #include<utility> #include<numeric> #include<algorithm> #include<bitset> #include<complex> using namespace std; typedef long long Int; typedef vector<int> vint; typedef pair<int,int> pint; #define mp make_pair template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; } template<class T> void chmin(T &t, T f) { if (t > f) t = f; } template<class T> void chmax(T &t, T f) { if (t < f) t = f; } int in() { int x; scanf("%d", &x); return x; } int main() { int i,n; scanf("%d\n",&n); for(i=0;i<n;i++){ string str; char s[300]; gets(s); str=s; //cout<<str<<endl; int a,b; for(a=1;a<26;a+=2){ if(a==13)continue; for(b=0;b<26;b++){ string st=""; int j; for(j=0;j<str.size();j++){ if(isalpha(str[j])){ st+=((str[j]-'a')*a+b)%26+'a'; }else{ st+=str[j]; } } //if(st[0]=='i')cout<<st<<endl; /*string::size_type index1=st.find("that"); string::size_type index2=st.find("this"); if(index1!=string::npos||index2!=string::npos){ cout<<st<<endl; goto end; }*/ } } end:; } return 0; }
a.cc: In function 'int main()': a.cc:37:17: error: 'gets' was not declared in this scope; did you mean 'getw'? 37 | gets(s); | ^~~~ | getw
s600430511
p00040
C++
#include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<cassert> #include<iostream> #include<sstream> #include<string> #include<vector> #include<queue> #include<set> #include<map> #include<utility> #include<numeric> #include<algorithm> #include<bitset> #include<complex> using namespace std; typedef long long Int; typedef vector<int> vint; typedef pair<int,int> pint; #define mp make_pair template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; } template<class T> void chmin(T &t, T f) { if (t > f) t = f; } template<class T> void chmax(T &t, T f) { if (t < f) t = f; } int in() { int x; scanf("%d", &x); return x; } int main() { int i,n; scanf("%d\n",&n); for(i=0;i<n;i++){ string str; char s[300]; gets(s); str=s; //cout<<str<<endl; int a,b; for(a=1;a<26;a+=2){ if(a==13)continue; for(b=0;b<26;b++){ string st=""; int j; for(j=0;j<str.size();j++){ if('a'<=str[j]&&str[j]<='z')){ st+=((str[j]-'a')*a+b)%26+'a'; }else{ st+=str[j]; } } //if(st[0]=='i')cout<<st<<endl; string::size_type index1=st.find("that"); string::size_type index2=st.find("this"); if(index1!=string::npos||index2!=string::npos){ cout<<st<<endl; goto end; } } } end:; } return 0; }
a.cc: In function 'int main()': a.cc:37:17: error: 'gets' was not declared in this scope; did you mean 'getw'? 37 | gets(s); | ^~~~ | getw a.cc:47:69: error: expected primary-expression before ')' token 47 | if('a'<=str[j]&&str[j]<='z')){ | ^
s763270826
p00040
C++
#include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<cassert> #include<iostream> #include<sstream> #include<string> #include<vector> #include<queue> #include<set> #include<map> #include<utility> #include<numeric> #include<algorithm> #include<bitset> #include<complex> using namespace std; typedef long long Int; typedef vector<int> vint; typedef pair<int,int> pint; #define mp make_pair template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; } template<class T> void chmin(T &t, T f) { if (t > f) t = f; } template<class T> void chmax(T &t, T f) { if (t < f) t = f; } int in() { int x; scanf("%d", &x); return x; } int main() { int i,n; scanf("%d\n",&n); for(i=0;i<n;i++){ string str; char s[300]; gets(s); str=s; //cout<<str<<endl; int a,b; for(a=1;a<26;a+=2){ if(a==13)continue; for(b=0;b<26;b++){ string st=""; int j; for(j=0;j<str.size();j++){ if('a'<=str[j]&&str[j]<='z'){ st+=((str[j]-'a')*a+b)%26+'a'; }else{ st+=str[j]; } } //if(st[0]=='i')cout<<st<<endl; string::size_type index1=st.find("that"); string::size_type index2=st.find("this"); if(index1!=string::npos||index2!=string::npos){ cout<<st<<endl; goto end; } } } end:; } return 0; }
a.cc: In function 'int main()': a.cc:37:17: error: 'gets' was not declared in this scope; did you mean 'getw'? 37 | gets(s); | ^~~~ | getw
s624065915
p00040
C++
#include <iostream> #include <string> #include <ctype.h> using namespace std; string solve(string cipher) { for ( ; ; ) { for (int a = 1; ; ++a) { if (__gcd(a, 26) != 1) continue; bool decrypt = false; for (int b = 0; b < 26; ++b) { string plain = cipher; for (unsigned int i = 0; i < plain.size(); ++i) { if (isalpha(plain[i])) plain[i] = ('a' + ((a * (plain[i]-'a') + b) % 26)); } if (plain.find("that") != string::npos || plain.find("this") != string::npos) return plain; } } } } int main() { int n; cin >> n; string cipher; getline(cin, cipher); for (int i = 0; i < n; ++i) { getline(cin, cipher); if (cipher.find_first_of("\n") != string::npos) cipher.erase(cipher.end()-1); if (cipher.find_first_of("\r") != string::npos) cipher.erase(cipher.end()-1); cout << solve(cipher) << endl; } return 0; }
a.cc: In function 'std::string solve(std::string)': a.cc:10:11: error: '__gcd' was not declared in this scope 10 | if (__gcd(a, 26) != 1) | ^~~~~
s089453875
p00040
C++
#include <iostream> #include <string> #define rep(i) for(I64 i=0;;++i) #define repn(i,n) for(I64 i=0;i<(n);++(i)) using namespace std; bool coprime(int a, int b){ int r, temp; if(a < b){ temp = a; a = b; b = temp; } do{ r = a % b; a = b; b = r; }while(r); if(a == 1) return true; else return false; } int main(){ char t[26]; int n; cin >> n; scanf("%*c"); repn(i, n){ string input; getline(cin, input); int len = input.size(); bool flag = false; rep(a){ if(coprime(26, a+1)){ repn(b, 26){ string res = ""; repn(r, 26){ t[r] = ((a+1) * r + b) % 26 + 'a'; } repn(j, len){ if(input[j] == ' ') res += ' '; else{ repn(k, 26){ if(input[j] == t[k]){ res += k + 'a'; break; } } } } if(res.find("this") != string::npos || res.find("that") != string::npos){ cout << res << endl; flag = true; break; } } if(flag) break; } if(flag) break; } } }
a.cc: In function 'int main()': a.cc:4:23: error: 'I64' was not declared in this scope 4 | #define repn(i,n) for(I64 i=0;i<(n);++(i)) | ^~~ a.cc:31:9: note: in expansion of macro 'repn' 31 | repn(i, n){ | ^~~~ a.cc:31:14: error: 'i' was not declared in this scope 31 | repn(i, n){ | ^ a.cc:4:31: note: in definition of macro 'repn' 4 | #define repn(i,n) for(I64 i=0;i<(n);++(i)) | ^ a.cc:37:21: error: expected ';' before 'a' 37 | rep(a){ | ^ a.cc:3:24: note: in definition of macro 'rep' 3 | #define rep(i) for(I64 i=0;;++i) | ^ a.cc:37:21: error: 'a' was not declared in this scope 37 | rep(a){ | ^ a.cc:3:31: note: in definition of macro 'rep' 3 | #define rep(i) for(I64 i=0;;++i) | ^ a.cc:39:38: error: expected ';' before 'b' 39 | repn(b, 26){ | ^ a.cc:4:27: note: in definition of macro 'repn' 4 | #define repn(i,n) for(I64 i=0;i<(n);++(i)) | ^ a.cc:39:38: error: 'b' was not declared in this scope 39 | repn(b, 26){ | ^ a.cc:4:31: note: in definition of macro 'repn' 4 | #define repn(i,n) for(I64 i=0;i<(n);++(i)) | ^ a.cc:41:46: error: expected ';' before 'r' 41 | repn(r, 26){ | ^ a.cc:4:27: note: in definition of macro 'repn' 4 | #define repn(i,n) for(I64 i=0;i<(n);++(i)) | ^ a.cc:41:46: error: 'r' was not declared in this scope 41 | repn(r, 26){ | ^ a.cc:4:31: note: in definition of macro 'repn' 4 | #define repn(i,n) for(I64 i=0;i<(n);++(i)) | ^ a.cc:44:46: error: expected ';' before 'j' 44 | repn(j, len){ | ^ a.cc:4:27: note: in definition of macro 'repn' 4 | #define repn(i,n) for(I64 i=0;i<(n);++(i)) | ^ a.cc:44:46: error: 'j' was not declared in this scope 44 | repn(j, len){ | ^ a.cc:4:31: note: in definition of macro 'repn' 4 | #define repn(i,n) for(I64 i=0;i<(n);++(i)) | ^ a.cc:47:62: error: expected ';' before 'k' 47 | repn(k, 26){ | ^ a.cc:4:27: note: in definition of macro 'repn' 4 | #define repn(i,n) for(I64 i=0;i<(n);++(i)) | ^ a.cc:47:62: error: 'k' was not declared in this scope 47 | repn(k, 26){ | ^ a.cc:4:31: note: in definition of macro 'repn' 4 | #define repn(i,n) for(I64 i=0;i<(n);++(i)) | ^
s919841007
p00040
C++
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Scanner; public class Main { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { Scanner cin = new Scanner(System.in); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ArrayList<Integer> list = new ArrayList<Integer>(); for(int i = 2; i < 100; i++){ if(gcm(26,i)==1){ list.add(i); } } String NN =br.readLine(); int N = Integer.parseInt(NN); while(N--!=0){ String str = br.readLine(); label:for(int i = 0; i < list.size(); i++){ for(int j = 0; j < 26; j++){ String nstr = ""; for(int k = 0; k < str.length(); k++){ if(Character.isLetter(str.charAt(k))){ nstr += (char)(((list.get(i)*(str.charAt(k)-'a') + j)%26) + 'a'); } else{ nstr += " " ; } //nstr+=str.charAt(k); } if(nstr.contains("that") || nstr.contains("this")){ System.out.println(nstr); break label; } } } } } static int gcm(int p, int q){ if(p < q){ int tmp=p; p=q; q=tmp; } if(q==0){ return p; } else{ return gcm(q, p%q); } } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.io.BufferedReader; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: 'import' does not name a type 2 | import java.io.IOException; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: 'import' does not name a type 3 | import java.io.InputStreamReader; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:1: error: 'import' does not name a type 4 | import java.util.ArrayList; | ^~~~~~ a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:5:1: error: 'import' does not name a type 5 | import java.util.Scanner; | ^~~~~~ a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:7:1: error: expected unqualified-id before 'public' 7 | public class Main { | ^~~~~~
s937251924
p00040
C++
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ArrayList<Integer> list = new ArrayList<Integer>(); for(int i = 2; i < 100; i++){ if(gcm(26,i)==1){ list.add(i); } } String NN =br.readLine(); int N = Integer.parseInt(NN); while(N--!=0){ String str = br.readLine(); label:for(int i = 0; i < list.size(); i++){ for(int j = 0; j < 26; j++){ String nstr = ""; for(int k = 0; k < str.length(); k++){ if(Character.isLetter(str.charAt(k))){ nstr += (char)(((list.get(i)*(str.charAt(k)-'a') + j)%26) + 'a'); } else{ nstr += " " ; } } if(nstr.contains("that") || nstr.contains("this")){ System.out.println(nstr); break label; } } } } } static int gcm(int p, int q){ if(p < q){ int tmp=p; p=q; q=tmp; } if(q==0){ return p; } else{ return gcm(q, p%q); } } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.io.BufferedReader; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: 'import' does not name a type 2 | import java.io.IOException; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: 'import' does not name a type 3 | import java.io.InputStreamReader; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:1: error: 'import' does not name a type 4 | import java.util.ArrayList; | ^~~~~~ a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:5:1: error: expected unqualified-id before 'public' 5 | public class Main { | ^~~~~~
s889476791
p00040
C++
#include<iostream> #include<string> #include<algorithm> using namespace std; int F(int alpha,int beta,int ch){ return (alpha*ch+beta)%26; } int gcd(int a,int b){ return b==0?a:gcd(b,a%b); } int main(){ int n; string in,s,ans; cin>>n; getline(cin,in); while(n--){ getline(cin,in); for(int i=1;i<26;i++){ if(gcd(26,i)!=1)continue; for(int j=0;j<26;j++){ for(int k=0;k<26;k++){ table[F(i,j,k)] = k; } s.resize(in.size()); for(int k=0;k<in.size();k++){ if(in[k]==' ')s[k]=' '; else s[k] = table[in[k]-'a']+'a'; } if(s.find("that",0)!=string::npos || s.find("this",0)!=string::npos){ cout<<s; goto BREAK; } } } BREAK:; } return 0; }
a.cc: In function 'int main()': a.cc:23:41: error: 'table' was not declared in this scope; did you mean 'mutable'? 23 | table[F(i,j,k)] = k; | ^~~~~ | mutable a.cc:28:53: error: 'table' was not declared in this scope; did you mean 'mutable'? 28 | else s[k] = table[in[k]-'a']+'a'; | ^~~~~ | mutable
s359252128
p00040
C++
#include <iostream> #include <vector> #include <string> #include <map> #include <cstdio> #include <sstream> #include <math.h> #include <boost/math/common_factor.hpp> using namespace std; string check(string str); map<char, int> create_table(); int main(){ char ch = 'a'; string str; int num; vector<string> answers; map<char,int> table = create_table(); cin >> num; cin.ignore(); for(int k=0; k<num; k++){ getline(cin, str); char c; char list[1]; bool flag = true; int beta; int alpha = 1; map<char, int>::iterator itr; while(flag){ if(boost::math::gcd(alpha,26) == 1){ for(beta=1; beta<26; beta++){ string result; for(int i=0; i<str.size(); i++){ c = str[i]; if(c != ' '){ sprintf(list, "%c", ch+(19*table[c]+20)%26); result += list[0]; }else{ result += ' '; } } if(result.find("this",0) !=string::npos || result.find("that",0) != string::npos){ answers.push_back(result); flag = false; break; } } } alpha++; } } for(int j=0; j<answers.size(); j++){ cout << answers[j] << endl; } return 0; } map<char, int> create_table(){ map<char, int> table; char ch[1]; char str = 'a'; for(int i=0; i<26; i++){ sprintf(ch, "%c", str+i); table.insert(pair<char,int>(ch[0],i)); } return table; }
a.cc:8:10: fatal error: boost/math/common_factor.hpp: No such file or directory 8 | #include <boost/math/common_factor.hpp> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated.
s766992738
p00041
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.regex.Pattern; import org.apache.el.stream.Stream; public class Main { public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader reader = new BufferedReader(new InputStreamReader( System.in)); StringBuilder builder = new StringBuilder(); while (true) { String line = reader.readLine(); if (line.equals("0 0 0 0")) { break; } int[] num = new int[4]; StringTokenizer tokenizer = new StringTokenizer(line); for (int i = 0; i < 4; i++) { num[i] = Integer.parseInt(tokenizer.nextToken()); } boolean flag = false; loop: for (int i = 0; i < 4; i++) { for (int j = i + 1; j < i + 4; j++) { for (int k = 0; k < 4; k++) { if (i == k || j % 4 == k) { continue; } for (int l = 0; l < 1; l++) { if (check(num[i], num[j % 4], num[k], num[6 - (i + j % 4 + k)])) { flag = true; break loop; } } } } } if (!flag) { System.out.println(0); } } } private static boolean check(int a, int b, int c, int d) { char[] chs = { '+', '-', '*' }; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { for (int k = 0; k < 3; k++) { if (cal(cal(cal(a, chs[i], b), chs[j], c), chs[k], d) == 10) { System.out.println(String.format( "(((%d %s %d) %s %d) %s %d)", a, chs[i], b, chs[j], c, chs[k], d)); return true; } else if (cal(cal(a, chs[i], b), chs[j], cal(c, chs[k], d)) == 10) { System.out.println(String.format( "((%d %s %d) %s (%d %s %d))", a, chs[i], b, chs[j], c, chs[k], d)); return true; } } } } return false; } private static int cal(int a, char c, int b) { switch (c) { case '+': return a + b; case '-': return a - b; default: return a * b; } } }
Main.java:8: error: package org.apache.el.stream does not exist import org.apache.el.stream.Stream; ^ 1 error
s954897625
p00041
Java
import java.io.IOException; import java.lang.reflect.Array; import java.util.*; class Main { public static void main(String[] args) throws Exception { Scanner in = new Scanner(System.in); while(in.hasNext()) { List<Integer> ints = new ArrayList<>(); ints.add(in.nextInt()); ints.add(in.nextInt()); ints.add(in.nextInt()); ints.add(in.nextInt()); if(ints.get(0) == 0) return; System.out.println(solve(ints)); } } /** * http://dai1741.github.io/maximum-algo-2012/docs/parsing/ */ static class Calc { int i; String s; private static final Map<String, Integer> opPriority = new HashMap<String, Integer>() { { put("+", 2); put("-", 2); put("*", 3); put("(", 3); put(")", 3); } }; public boolean isOperator(String token) { return opPriority.containsKey(token); } public int calc(String exp) throws Exception { i=0; s = exp; s = s.replaceAll(" ", ""); return expr(); } public int expr() throws Exception { int val = term(); while(i < s.length() && (s.charAt(i) == '+' || s.charAt(i) == '-')) { char op = s.charAt(i); i++; int val2 = term(); if (op == '+') val += val2; else val -= val2; } return val; } public int term() throws Exception { int val = factor(); while(i < s.length() && s.charAt(i) == '*') { char op = s.charAt(i); i++; int val2 = factor(); val *= val2; } return val; } public int factor() throws Exception { if(Character.isDigit(s.charAt(i))) { return number(); } if(s.charAt(i) != '(') { new Exception(); } i++; int ret = expr(); if(s.charAt(i) != ')') { new Exception(); } i++; return ret; } public int number() throws Exception { int n = Integer.parseInt(""+s.charAt(i)); i++; while(i < s.length() && Character.isDigit(s.charAt(i))) { n = n * 10 + Integer.parseInt(""+s.charAt(i)); i++; } return n; } }; public static String solve(List<Integer> ints) throws Exception { String[] exps={ "(a x a) x a x a", "(a x a x a) x a", "((a x a) x a) x a", "(a x (a x a)) x a", "a x (a x a) x a", "a x (a x a x a)", "a x ((a x a) x a)", "a x (a x (a x a))" "a x a x (a x a)", }; String[] ops = {"+","-","*"}; for(int a=0;a<4;a++) { for(int b=0;b<4;b++) { if(a == b) continue; for(int c=0;c<4;c++) { if(a == c || b == c) continue; for(int d=0;d<4;d++) { if(a == d || b == d || c == d) continue; for(int e=0;e<3;e++) { for(int f=0;f<3;f++) { for (int g = 0; g < 3; g++) { for (int i = 0; i < exps.length; i++) { String exp = exps[i]; String buf = new String(exp); buf = buf.substring(0, buf.indexOf('a')) + ints.get(a) + buf.substring(buf.indexOf('a')+1); buf = buf.substring(0, buf.indexOf('a')) + ints.get(b) + buf.substring(buf.indexOf('a')+1); buf = buf.substring(0, buf.indexOf('a')) + ints.get(c) + buf.substring(buf.indexOf('a')+1); buf = buf.substring(0, buf.indexOf('a')) + ints.get(d) + buf.substring(buf.indexOf('a')+1); buf = buf.substring(0, buf.indexOf('x')) + ops[e] + buf.substring(buf.indexOf('x')+1); buf = buf.substring(0, buf.indexOf('x')) + ops[f] + buf.substring(buf.indexOf('x')+1); buf = buf.substring(0, buf.indexOf('x')) + ops[g] + buf.substring(buf.indexOf('x')+1); if((new Calc().calc(buf)) == 10) { return buf; } } } } } } } } } return "0"; } }
Main.java:106: error: '}' expected "a x (a x (a x a))" ^ Main.java:110: error: illegal start of type for(int a=0;a<4;a++) { ^ Main.java:110: error: illegal start of type for(int a=0;a<4;a++) { ^ Main.java:110: error: <identifier> expected for(int a=0;a<4;a++) { ^ Main.java:141: error: illegal start of type return "0"; ^ Main.java:143: error: class, interface, enum, or record expected } ^ 6 errors
s592206810
p00041
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.LinkedList; import java.util.Queue; public class Main{ static int NUM = 4; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = null; while ((line = br.readLine()) != null) { line = line.trim(); if (line.equals("0 0 0 0")) break; String[] splited = line.trim().split(" "); int[] num = new int[NUM]; for (int i = 0; i < NUM; i++) { num[i] = Integer.parseInt(splited[i]); } // 演算子の組み合わせ String result = null; result = opeCombination(num); if(result == null) result = "0"; System.out.println(result); count = 0; } } /* * 数の組み合わせ一覧を作成する * 処理はキューで行い発見したら終了 * @param is 組み合わせる数値配列 * */ private static String opeCombination(int[] is) { Queue<DataSet> que = new LinkedList<DataSet>(); ArrayList<DataSet> queIndex1 = new ArrayList<DataSet>(); for (int i = 0; i < is.length; i++) { DataSet p = new DataSet(is[i], 0, 1 << i, Integer.toString(is[i])); que.offer(p); } while (!que.isEmpty()) { DataSet pf = que.poll(); if (pf.sumCount == 1) { queIndex1.add(pf); } if (pf.sumCount == NUM - 1 && pf.sum == 10) { return pf.ope; } for (int i = 0; i < is.length; i++) { if (((pf.index >> i) & 1) != 1) { for (int j = 0; j < 3; j++) { DataSet pa = new DataSet(); switch (j) { case 0: pa.sum = pf.sum + is[i]; pa.ope = "(" + pf.ope + "+" + is[i] + ")"; break; case 1: pa.sum = pf.sum - is[i]; pa.ope = "(" + pf.ope + "-" + is[i] + ")"; break; case 2: pa.sum = pf.sum * is[i]; pa.ope = pf.ope + "*" + is[i]; break; } pa.sumCount = pf.sumCount + 1; pa.index = pf.index + (1 << i); if ((pa.sumCount == 2 && pa.sum < 0) || (pa.sumCount == 2 && pa.sum > 20)) continue; que.offer(pa); } } } } // (a ope b) ope (c ope d) for (int i = 0; i < queIndex1.size() - 1; i++) { for (int j = 0; j < queIndex1.size(); j++) { if ((queIndex1.get(i).index + queIndex1.get(j).index) == 0xf) { int sum = 0; String ope = null; for (int k = 0; k < 3; k++) { switch (k) { case 0: sum = queIndex1.get(i).sum + queIndex1.get(j).sum; ope = queIndex1.get(i).ope + "+" + queIndex1.get(j).ope; break; case 1: sum = queIndex1.get(i).sum - queIndex1.get(j).sum; ope = queIndex1.get(i).ope + "-" + queIndex1.get(j).ope; break; case 2: sum = queIndex1.get(i).sum * queIndex1.get(j).sum; ope = queIndex1.get(i).ope + "*" + queIndex1.get(j).ope; break; } if (sum == 10) return ope; } } } } return null; } class DataSet { int sum; //演算結果 int sumCount; //演算回数 int index; //使用した数値の添字(ビットで管理) String ope = null; //演算式 DataSet(int _sum, int _sumCount, int _index, String _ope) { sum = _sum; sumCount = _sumCount; index = _index; ope = _ope; } public DataSet() { } }
Main.java:141: error: reached end of file while parsing } ^ 1 error
s634986639
p00041
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.LinkedList; import java.util.Queue; public class Main{ static int NUM = 4; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = null; while ((line = br.readLine()) != null) { line = line.trim(); if (line.equals("0 0 0 0")) break; String[] splited = line.trim().split(" "); int[] num = new int[NUM]; for (int i = 0; i < NUM; i++) { num[i] = Integer.parseInt(splited[i]); } // 演算子の組み合わせ String result = null; result = opeCombination(num); if(result == null) result = "0"; System.out.println(result); } } /* * 数の組み合わせ一覧を作成する * 処理はキューで行い発見したら終了 * @param is 組み合わせる数値配列 * */ private static String opeCombination(int[] is) { Queue<DataSet> que = new LinkedList<DataSet>(); ArrayList<DataSet> queIndex1 = new ArrayList<DataSet>(); for (int i = 0; i < is.length; i++) { DataSet p = new DataSet(is[i], 0, 1 << i, Integer.toString(is[i])); que.offer(p); } while (!que.isEmpty()) { DataSet pf = que.poll(); if (pf.sumCount == 1) { queIndex1.add(pf); } if (pf.sumCount == NUM - 1 && pf.sum == 10) { return pf.ope; } for (int i = 0; i < is.length; i++) { if (((pf.index >> i) & 1) != 1) { for (int j = 0; j < 3; j++) { DataSet pa = new DataSet(); switch (j) { case 0: pa.sum = pf.sum + is[i]; pa.ope = "(" + pf.ope + "+" + is[i] + ")"; break; case 1: pa.sum = pf.sum - is[i]; pa.ope = "(" + pf.ope + "-" + is[i] + ")"; break; case 2: pa.sum = pf.sum * is[i]; pa.ope = pf.ope + "*" + is[i]; break; } pa.sumCount = pf.sumCount + 1; pa.index = pf.index + (1 << i); if ((pa.sumCount == 2 && pa.sum < 0) || (pa.sumCount == 2 && pa.sum > 20)) continue; que.offer(pa); } } } } // (a ope b) ope (c ope d) for (int i = 0; i < queIndex1.size() - 1; i++) { for (int j = 0; j < queIndex1.size(); j++) { if ((queIndex1.get(i).index + queIndex1.get(j).index) == 0xf) { int sum = 0; String ope = null; for (int k = 0; k < 3; k++) { switch (k) { case 0: sum = queIndex1.get(i).sum + queIndex1.get(j).sum; ope = queIndex1.get(i).ope + "+" + queIndex1.get(j).ope; break; case 1: sum = queIndex1.get(i).sum - queIndex1.get(j).sum; ope = queIndex1.get(i).ope + "-" + queIndex1.get(j).ope; break; case 2: sum = queIndex1.get(i).sum * queIndex1.get(j).sum; ope = queIndex1.get(i).ope + "*" + queIndex1.get(j).ope; break; } if (sum == 10) return ope; } } } } return null; } class DataSet { int sum; //演算結果 int sumCount; //演算回数 int index; //使用した数値の添字(ビットで管理) String ope = null; //演算式 DataSet(int _sum, int _sumCount, int _index, String _ope) { sum = _sum; sumCount = _sumCount; index = _index; ope = _ope; } public DataSet() { } }
Main.java:140: error: reached end of file while parsing } ^ 1 error
s274456267
p00041
C
typedef string::const_iterator State; const string C[5] = {"((a x b) x c) x d", "(a x (b x c)) x d", "a x ((b x c) x d)", "a x (b x (c x d))", "(a x b) x (c x d)"}; const char P[3] = {'+','-','*'}; int term(State &now); int expression(State &now); int fact(State &now); int number(State &now); string solve(int a,int b,int c,int d){ for(int i = 0; i < 5; i++){ string s = C[i]; s[s.find("a")] = '0' + a; s[s.find("b")] = '0' + b; s[s.find("c")] = '0' + c; s[s.find("d")] = '0' + d; for(int p1 = 0; p1 < 3; p1++){ for(int p2 = 0; p2 < 3; p2++){ for(int p3 = 0; p3 < 3; p3++){ string s2 = s; s2[s2.find("x")] = P[p1]; s2[s2.find("x")] = P[p2]; s2[s2.find("x")] = P[p3]; string s3 = s2; s3.erase(remove(all(s3),' '),s3.end()); State now = s3.begin(); int ans = expression(now); if(ans == 10) return s2; } } } } return ""; } int main(){ int a = 0,b = 0,c = 0,d = 0; while(scanf("%d %d %d %d",&a,&b,&c,&d),a|b|c|d){ int st[4] = {a,b,c,d}; sort(st,st + 4); bool exist = false; string res; do{ res = solve(st[0],st[1],st[2],st[3]); if(res != ""){ exist = true; break; } }while(next_permutation(st,st + 4)); if(exist){ string r = "(" + res + ")"; cout<<r<<endl; } else puts("0"); } } int term(State &now){ int ret = fact(now); while(true){ if(*now == '*'){ now++; ret *= fact(now); }else break; } return ret; } int expression(State &now){ int ret = term(now); while(true){ if(*now == '+'){ now++; ret += term(now); }else if(*now == '-'){ now++; ret -= term(now); }else break; } return ret; } int fact(State &now){ if(*now == '('){ now++; int ret = expression(now); now++; return ret; }else{ return number(now); } } int number(State &now){ int ret = 0; while('0' <= (*now) && (*now) <= '9'){ ret *= 10; ret += *now - '0'; now++; } return ret; }
main.c:1:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before '::' token 1 | typedef string::const_iterator State; | ^~ main.c:3:7: error: unknown type name 'string' 3 | const string C[5] = {"((a x b) x c) x d", | ^~~~~~ main.c:4:22: error: excess elements in 'const int[5]' initializer 4 | "(a x (b x c)) x d", | ^~~~~~~~~~~~~~~~~~~ main.c:4:22: note: (near initialization for 'C') main.c:5:22: error: excess elements in 'const int[5]' initializer 5 | "a x ((b x c) x d)", | ^~~~~~~~~~~~~~~~~~~ main.c:5:22: note: (near initialization for 'C') main.c:6:22: error: excess elements in 'const int[5]' initializer 6 | "a x (b x (c x d))", | ^~~~~~~~~~~~~~~~~~~ main.c:6:22: note: (near initialization for 'C') main.c:7:22: error: excess elements in 'const int[5]' initializer 7 | "(a x b) x (c x d)"}; | ^~~~~~~~~~~~~~~~~~~ main.c:7:22: note: (near initialization for 'C') main.c:3:21: error: cannot initialize array of 'int' from a string literal with type array of 'char' 3 | const string C[5] = {"((a x b) x c) x d", | ^ main.c:11:15: error: expected ')' before '&' token 11 | int term(State &now); | ^~ | ) main.c:12:21: error: expected ')' before '&' token 12 | int expression(State &now); | ^~ | ) main.c:13:15: error: expected ')' before '&' token 13 | int fact(State &now); | ^~ | ) main.c:14:17: error: expected ')' before '&' token 14 | int number(State &now); | ^~ | ) main.c:16:1: error: unknown type name 'string' 16 | string solve(int a,int b,int c,int d){ | ^~~~~~ main.c: In function 'solve': main.c:18:5: error: unknown type name 'string' 18 | string s = C[i]; | ^~~~~~ main.c:19:8: error: request for member 'find' in something not a structure or union 19 | s[s.find("a")] = '0' + a; | ^ main.c:20:8: error: request for member 'find' in something not a structure or union 20 | s[s.find("b")] = '0' + b; | ^ main.c:21:8: error: request for member 'find' in something not a structure or union 21 | s[s.find("c")] = '0' + c; | ^ main.c:22:8: error: request for member 'find' in something not a structure or union 22 | s[s.find("d")] = '0' + d; | ^ main.c:26:11: error: unknown type name 'string' 26 | string s2 = s; | ^~~~~~ main.c:27:16: error: request for member 'find' in something not a structure or union 27 | s2[s2.find("x")] = P[p1]; | ^ main.c:28:16: error: request for member 'find' in something not a structure or union 28 | s2[s2.find("x")] = P[p2]; | ^ main.c:29:16: error: request for member 'find' in something not a structure or union 29 | s2[s2.find("x")] = P[p3]; | ^ main.c:30:11: error: unknown type name 'string' 30 | string s3 = s2; | ^~~~~~ main.c:31:13: error: request for member 'erase' in something not a structure or union 31 | s3.erase(remove(all(s3),' '),s3.end()); | ^ main.c:31:20: error: implicit declaration of function 'remove' [-Wimplicit-function-declaration] 31 | s3.erase(remove(all(s3),' '),s3.end()); | ^~~~~~ main.c:31:27: error: implicit declaration of function 'all' [-Wimplicit-function-declaration] 31 | s3.erase(remove(all(s3),' '),s3.end()); | ^~~ main.c:31:42: error: request for member 'end' in something not a structure or union 31 | s3.erase(remove(all(s3),' '),s3.end()); | ^ main.c:32:11: error: unknown type name 'State' 32 | State now = s3.begin(); | ^~~~~ main.c:32:25: error: request for member 'begin' in something not a structure or union 32 | State now = s3.begin(); | ^ main.c:33:21: error: implicit declaration of function 'expression' [-Wimplicit-function-declaration] 33 | int ans = expression(now); | ^~~~~~~~~~ main.c:39:10: error: returning 'char *' from a function with return type 'int' makes integer from pointer without a cast [-Wint-conversion] 39 | return ""; | ^~ main.c: In function 'main': main.c:44:9: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 44 | while(scanf("%d %d %d %d",&a,&b,&c,&d),a|b|c|d){ | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | typedef string::const_iterator State; main.c:44:9: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 44 | while(scanf("%d %d %d %d",&a,&b,&c,&d),a|b|c|d){ | ^~~~~ main.c:44:9: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:46:5: error: implicit declaration of function 'sort' [-Wimplicit-function-declaration] 46 | sort(st,st + 4); | ^~~~ main.c:47:5: error: unknown type name 'bool' 47 | bool exist = false; | ^~~~ main.c:1:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' +++ |+#include <stdbool.h> 1 | typedef string::const_iterator State; main.c:47:18: error: 'false' undeclared (first use in this function) 47 | bool exist = false; | ^~~~~ main.c:47:18: note: 'false' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' main.c:47:18: note: each undeclared identifier is reported only once for each function it appears in main.c:48:5: error: unknown type name 'string' 48 | string res; | ^~~~~~ main.c:51:14: warning: comparison between pointer and integer 51 | if(res != ""){ | ^~ main.c:52:17: error: 'true' undeclared (first use in this function) 52 | exist = true; | ^~~~ main.c:52:17: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' main.c:55:12: error: implicit declaration of function 'next_permutation' [-Wimplicit-function-declaration] 55 | }while(next_permutation(st,st + 4)); | ^~~~~~~~~~~~~~~~ main.c:57:7: error: unknown type name 'string' 57 | string r = "(" + res + ")"; | ^~~~~~ main.c:57:28: error: invalid operands to binary + (have 'char *' and 'char *') 57 | string r = "(" + res + ")"; | ~~~~~~~~~ ^ | | | | | char * | char * main.c:58:7: error: 'cout' undeclared (first use in this function) 58 | cout<<r<<endl; | ^~~~ main.c:58:16: error: 'endl' undeclared (first use in this function) 58 | cout<<r<<endl; | ^~~~ main.c:60:10: error: implicit declaration of function 'puts' [-Wimplicit-function-declaration] 60 | else puts("0"); | ^~~~ main.c:60:10: note: include '<stdio.h>' or provide a declaration of 'puts' main.c: At top level: main.c:64:15: error: expected ')' before '&' token 64 | int term(State &now){ | ^~ | ) main.c:75:21: error: expected ')' before '&' token 75 | int expression(State &now){ | ^~ | ) main.c:89:15: error: expected ')' before '&' token 89 | int fact(State &now){ | ^~ | ) main.c:100:17: error: expected ')' before '&' token 100 | int number(State &now){ | ^~ | )
s214254008
p00041
C
#include<stdio.h> #include<stdlib.h> int calc(int x, int y, int z) { switch (z){ case 0: return (x + y); case 1: return (x - y); case 2: return (x * y); } } int hantei(int a, int b, int c, int d){ char en[3]={'+','-','*'}; for(i=0;i<3;i++){ for(j=0;j<3;j++){ int(k=0;k<3;k++){ if (calc(calc(a, b, i), calc(c, d, j), k) == 10){ return printf("(%d%c%d)%c(%d%c%d)\n", a, en[i], b, en[k], c, en[j], d); } if (calc(calc(calc(a, b, i), c, j), d, k) == 10){ return printf("((%d%c%d)%c%d)%c%d\n", a, en[i], b, en[j], c, en[k], d); } } } } return 0; } int main(void){ int a, b, c, d; while (scanf("%d %d %d %d", &a, &b, &c, &d)!=EOF){ if(check(a, b, c, d)) continue;//??¨??????????????´????????? else if(check(a, b, d, c)) continue; else if(check(a, c, b, d)) continue; else if(check(a, c, d, b)) continue; else if(check(a, d, b, c)) continue; else if(check(a, d, c, b)) continue; else if(check(b, a, d, c)) continue; else if(check(b, a, c, d)) continue; else if(check(b, c, a, d)) continue; else if(check(b, c, d, a)) continue; else if(check(b, d, a, c)) continue; else if(check(b, d, c, a)) continue; else if(check(c, a, b, d)) continue; else if(check(c, a, d, b)) continue; else if(check(c, b, a, d)) continue; else if(check(c, b, d, a)) continue; else if(check(c, d, a, b)) continue; else if(check(c, d, b, a)) continue; else if(check(d, a, b, c)) continue; else if(check(d, a, c, b)) continue; else if(check(d, b, a, c)) continue; else if(check(d, b, c, a)) continue; else if(check(d, c, a, b)) continue; else if(check(d, c, b, a)) continue; printf("0\n"); } return 0; }
main.c: In function 'hantei': main.c:13:9: error: 'i' undeclared (first use in this function) 13 | for(i=0;i<3;i++){ | ^ main.c:13:9: note: each undeclared identifier is reported only once for each function it appears in main.c:14:11: error: 'j' undeclared (first use in this function) 14 | for(j=0;j<3;j++){ | ^ main.c:15:14: error: expected ')' before '=' token 15 | int(k=0;k<3;k++){ | ^ | ) main.c: In function 'main': main.c:30:8: error: implicit declaration of function 'check' [-Wimplicit-function-declaration] 30 | if(check(a, b, c, d)) continue;//??¨??????????????´????????? | ^~~~~
s447380197
p00041
C
#include<stdio.h> #include<stdlib.h> int calc(int x, int y, int z) { switch (z){ case 0: return (x + y); case 1: return (x - y); case 2: return (x * y); } } int hantei(int a, int b, int c, int d){ char en[3]={'+','-','*'}; int i,j,k; for(i=0;i<3;i++){ for(j=0;j<3;j++){ int(k=0;k<3;k++){ if (calc(calc(a, b, i), calc(c, d, j), k) == 10){ return printf("(%d%c%d)%c(%d%c%d)\n", a, en[i], b, en[k], c, en[j], d); } if (calc(calc(calc(a, b, i), c, j), d, k) == 10){ return printf("((%d%c%d)%c%d)%c%d\n", a, en[i], b, en[j], c, en[k], d); } } } } return 0; } int main(void){ int a, b, c, d; while (scanf("%d %d %d %d", &a, &b, &c, &d)!=EOF){ if(check(a, b, c, d)) continue;//??¨??????????????´????????? else if(check(a, b, d, c)) continue; else if(check(a, c, b, d)) continue; else if(check(a, c, d, b)) continue; else if(check(a, d, b, c)) continue; else if(check(a, d, c, b)) continue; else if(check(b, a, d, c)) continue; else if(check(b, a, c, d)) continue; else if(check(b, c, a, d)) continue; else if(check(b, c, d, a)) continue; else if(check(b, d, a, c)) continue; else if(check(b, d, c, a)) continue; else if(check(c, a, b, d)) continue; else if(check(c, a, d, b)) continue; else if(check(c, b, a, d)) continue; else if(check(c, b, d, a)) continue; else if(check(c, d, a, b)) continue; else if(check(c, d, b, a)) continue; else if(check(d, a, b, c)) continue; else if(check(d, a, c, b)) continue; else if(check(d, b, a, c)) continue; else if(check(d, b, c, a)) continue; else if(check(d, c, a, b)) continue; else if(check(d, c, b, a)) continue; printf("0\n"); } return 0; }
main.c: In function 'hantei': main.c:17:14: error: expected ')' before '=' token 17 | int(k=0;k<3;k++){ | ^ | ) main.c: In function 'main': main.c:32:8: error: implicit declaration of function 'check' [-Wimplicit-function-declaration] 32 | if(check(a, b, c, d)) continue;//??¨??????????????´????????? | ^~~~~
s641823556
p00041
C
#include<stdio.h> #include<stdlib.h> int calc(int x, int y, int z) { switch (z){ case 0: return (x + y); case 1: return (x - y); case 2: return (x * y); } } int hantei(int a, int b, int c, int d){ int i,j,k; char en[3]={'+','-','*'}; for(i=0;i<3;i++){ for(j=0;j<3;j++){ for(k=0;k<3;k++){ if (calc(calc(a, b, i), calc(c, d, j), k) == 10){ return printf("(%d%c%d)%c(%d%c%d)\n", a, en[i], b, en[k], c, en[j], d); } if (calc(calc(calc(a, b, i), c, j), d, k) == 10){ return printf("((%d%c%d)%c%d)%c%d\n", a, en[i], b, en[j], c, en[k], d); } } } } return 0; } int main(void){ int a, b, c, d; while (scanf("%d %d %d %d", &a, &b, &c, &d)!=EOF){ if(check(a, b, c, d)) continue;//??¨??????????????´????????? else if(check(a, b, d, c)) continue; else if(check(a, c, b, d)) continue; else if(check(a, c, d, b)) continue; else if(check(a, d, b, c)) continue; else if(check(a, d, c, b)) continue; else if(check(b, a, d, c)) continue; else if(check(b, a, c, d)) continue; else if(check(b, c, a, d)) continue; else if(check(b, c, d, a)) continue; else if(check(b, d, a, c)) continue; else if(check(b, d, c, a)) continue; else if(check(c, a, b, d)) continue; else if(check(c, a, d, b)) continue; else if(check(c, b, a, d)) continue; else if(check(c, b, d, a)) continue; else if(check(c, d, a, b)) continue; else if(check(c, d, b, a)) continue; else if(check(d, a, b, c)) continue; else if(check(d, a, c, b)) continue; else if(check(d, b, a, c)) continue; else if(check(d, b, c, a)) continue; else if(check(d, c, a, b)) continue; else if(check(d, c, b, a)) continue; printf("0\n"); } return 0; }
main.c: In function 'main': main.c:31:8: error: implicit declaration of function 'check' [-Wimplicit-function-declaration] 31 | if(check(a, b, c, d)) continue;//??¨??????????????´????????? | ^~~~~
s417096073
p00041
C
d[4],e[9],f,k;char s[30];z(){int b,c,a=e[f++];a>9?s[k++]=40,b=z(),s[k++]=a,c=z(),s[k++]=41,a=a-43?a-45?b*c:b-c:b+c:(s[k++]=a+48);return a;}y(o,n,i,j){if(i==7){f=k=0;if(z()==10){s[k]=0;puts(s);return 1;}return 0;}if(o)for(;j--;){e[i]="+-*"[];if(y(o-1,n+1,i+1,3))return 1;}if(n|i==6)for(j=4;j--;)if(e[i]=d[j]){d[j]=0;if(y(o,n-1,i+1,3))return 1;d[j]=e[i];}return 0;}main(){for(;scanf("%d%d%d%d",d,d+1,d+2,d+3),f=*d;)y(3,0,0,3)||puts("0");}
main.c:1:1: warning: data definition has no type or storage class 1 | d[4],e[9],f,k;char s[30];z(){int b,c,a=e[f++];a>9?s[k++]=40,b=z(),s[k++]=a,c=z(),s[k++]=41,a=a-43?a-45?b*c:b-c:b+c:(s[k++]=a+48);return a;}y(o,n,i,j){if(i==7){f=k=0;if(z()==10){s[k]=0;puts(s);return 1;}return 0;}if(o)for(;j--;){e[i]="+-*"[];if(y(o-1,n+1,i+1,3))return 1;}if(n|i==6)for(j=4;j--;)if(e[i]=d[j]){d[j]=0;if(y(o,n-1,i+1,3))return 1;d[j]=e[i];}return 0;}main(){for(;scanf("%d%d%d%d",d,d+1,d+2,d+3),f=*d;)y(3,0,0,3)||puts("0");} | ^ main.c:1:1: error: type defaults to 'int' in declaration of 'd' [-Wimplicit-int] main.c:1:6: error: type defaults to 'int' in declaration of 'e' [-Wimplicit-int] 1 | d[4],e[9],f,k;char s[30];z(){int b,c,a=e[f++];a>9?s[k++]=40,b=z(),s[k++]=a,c=z(),s[k++]=41,a=a-43?a-45?b*c:b-c:b+c:(s[k++]=a+48);return a;}y(o,n,i,j){if(i==7){f=k=0;if(z()==10){s[k]=0;puts(s);return 1;}return 0;}if(o)for(;j--;){e[i]="+-*"[];if(y(o-1,n+1,i+1,3))return 1;}if(n|i==6)for(j=4;j--;)if(e[i]=d[j]){d[j]=0;if(y(o,n-1,i+1,3))return 1;d[j]=e[i];}return 0;}main(){for(;scanf("%d%d%d%d",d,d+1,d+2,d+3),f=*d;)y(3,0,0,3)||puts("0");} | ^ main.c:1:11: error: type defaults to 'int' in declaration of 'f' [-Wimplicit-int] 1 | d[4],e[9],f,k;char s[30];z(){int b,c,a=e[f++];a>9?s[k++]=40,b=z(),s[k++]=a,c=z(),s[k++]=41,a=a-43?a-45?b*c:b-c:b+c:(s[k++]=a+48);return a;}y(o,n,i,j){if(i==7){f=k=0;if(z()==10){s[k]=0;puts(s);return 1;}return 0;}if(o)for(;j--;){e[i]="+-*"[];if(y(o-1,n+1,i+1,3))return 1;}if(n|i==6)for(j=4;j--;)if(e[i]=d[j]){d[j]=0;if(y(o,n-1,i+1,3))return 1;d[j]=e[i];}return 0;}main(){for(;scanf("%d%d%d%d",d,d+1,d+2,d+3),f=*d;)y(3,0,0,3)||puts("0");} | ^ main.c:1:13: error: type defaults to 'int' in declaration of 'k' [-Wimplicit-int] 1 | d[4],e[9],f,k;char s[30];z(){int b,c,a=e[f++];a>9?s[k++]=40,b=z(),s[k++]=a,c=z(),s[k++]=41,a=a-43?a-45?b*c:b-c:b+c:(s[k++]=a+48);return a;}y(o,n,i,j){if(i==7){f=k=0;if(z()==10){s[k]=0;puts(s);return 1;}return 0;}if(o)for(;j--;){e[i]="+-*"[];if(y(o-1,n+1,i+1,3))return 1;}if(n|i==6)for(j=4;j--;)if(e[i]=d[j]){d[j]=0;if(y(o,n-1,i+1,3))return 1;d[j]=e[i];}return 0;}main(){for(;scanf("%d%d%d%d",d,d+1,d+2,d+3),f=*d;)y(3,0,0,3)||puts("0");} | ^ main.c:1:26: error: return type defaults to 'int' [-Wimplicit-int] 1 | d[4],e[9],f,k;char s[30];z(){int b,c,a=e[f++];a>9?s[k++]=40,b=z(),s[k++]=a,c=z(),s[k++]=41,a=a-43?a-45?b*c:b-c:b+c:(s[k++]=a+48);return a;}y(o,n,i,j){if(i==7){f=k=0;if(z()==10){s[k]=0;puts(s);return 1;}return 0;}if(o)for(;j--;){e[i]="+-*"[];if(y(o-1,n+1,i+1,3))return 1;}if(n|i==6)for(j=4;j--;)if(e[i]=d[j]){d[j]=0;if(y(o,n-1,i+1,3))return 1;d[j]=e[i];}return 0;}main(){for(;scanf("%d%d%d%d",d,d+1,d+2,d+3),f=*d;)y(3,0,0,3)||puts("0");} | ^ main.c:1:140: error: return type defaults to 'int' [-Wimplicit-int] 1 | d[4],e[9],f,k;char s[30];z(){int b,c,a=e[f++];a>9?s[k++]=40,b=z(),s[k++]=a,c=z(),s[k++]=41,a=a-43?a-45?b*c:b-c:b+c:(s[k++]=a+48);return a;}y(o,n,i,j){if(i==7){f=k=0;if(z()==10){s[k]=0;puts(s);return 1;}return 0;}if(o)for(;j--;){e[i]="+-*"[];if(y(o-1,n+1,i+1,3))return 1;}if(n|i==6)for(j=4;j--;)if(e[i]=d[j]){d[j]=0;if(y(o,n-1,i+1,3))return 1;d[j]=e[i];}return 0;}main(){for(;scanf("%d%d%d%d",d,d+1,d+2,d+3),f=*d;)y(3,0,0,3)||puts("0");} | ^ main.c: In function 'y': main.c:1:140: error: type of 'o' defaults to 'int' [-Wimplicit-int] main.c:1:140: error: type of 'n' defaults to 'int' [-Wimplicit-int] main.c:1:140: error: type of 'i' defaults to 'int' [-Wimplicit-int] main.c:1:140: error: type of 'j' defaults to 'int' [-Wimplicit-int] main.c:1:185: error: implicit declaration of function 'puts' [-Wimplicit-function-declaration] 1 | d[4],e[9],f,k;char s[30];z(){int b,c,a=e[f++];a>9?s[k++]=40,b=z(),s[k++]=a,c=z(),s[k++]=41,a=a-43?a-45?b*c:b-c:b+c:(s[k++]=a+48);return a;}y(o,n,i,j){if(i==7){f=k=0;if(z()==10){s[k]=0;puts(s);return 1;}return 0;}if(o)for(;j--;){e[i]="+-*"[];if(y(o-1,n+1,i+1,3))return 1;}if(n|i==6)for(j=4;j--;)if(e[i]=d[j]){d[j]=0;if(y(o,n-1,i+1,3))return 1;d[j]=e[i];}return 0;}main(){for(;scanf("%d%d%d%d",d,d+1,d+2,d+3),f=*d;)y(3,0,0,3)||puts("0");} | ^~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'puts' +++ |+#include <stdio.h> 1 | d[4],e[9],f,k;char s[30];z(){int b,c,a=e[f++];a>9?s[k++]=40,b=z(),s[k++]=a,c=z(),s[k++]=41,a=a-43?a-45?b*c:b-c:b+c:(s[k++]=a+48);return a;}y(o,n,i,j){if(i==7){f=k=0;if(z()==10){s[k]=0;puts(s);return 1;}return 0;}if(o)for(;j--;){e[i]="+-*"[];if(y(o-1,n+1,i+1,3))return 1;}if(n|i==6)for(j=4;j--;)if(e[i]=d[j]){d[j]=0;if(y(o,n-1,i+1,3))return 1;d[j]=e[i];}return 0;}main(){for(;scanf("%d%d%d%d",d,d+1,d+2,d+3),f=*d;)y(3,0,0,3)||puts("0");} main.c:1:240: error: expected expression before ']' token 1 | d[4],e[9],f,k;char s[30];z(){int b,c,a=e[f++];a>9?s[k++]=40,b=z(),s[k++]=a,c=z(),s[k++]=41,a=a-43?a-45?b*c:b-c:b+c:(s[k++]=a+48);return a;}y(o,n,i,j){if(i==7){f=k=0;if(z()==10){s[k]=0;puts(s);return 1;}return 0;}if(o)for(;j--;){e[i]="+-*"[];if(y(o-1,n+1,i+1,3))return 1;}if(n|i==6)for(j=4;j--;)if(e[i]=d[j]){d[j]=0;if(y(o,n-1,i+1,3))return 1;d[j]=e[i];}return 0;}main(){for(;scanf("%d%d%d%d",d,d+1,d+2,d+3),f=*d;)y(3,0,0,3)||puts("0");} | ^ main.c: At top level: main.c:1:364: error: return type defaults to 'int' [-Wimplicit-int] 1 | d[4],e[9],f,k;char s[30];z(){int b,c,a=e[f++];a>9?s[k++]=40,b=z(),s[k++]=a,c=z(),s[k++]=41,a=a-43?a-45?b*c:b-c:b+c:(s[k++]=a+48);return a;}y(o,n,i,j){if(i==7){f=k=0;if(z()==10){s[k]=0;puts(s);return 1;}return 0;}if(o)for(;j--;){e[i]="+-*"[];if(y(o-1,n+1,i+1,3))return 1;}if(n|i==6)for(j=4;j--;)if(e[i]=d[j]){d[j]=0;if(y(o,n-1,i+1,3))return 1;d[j]=e[i];}return 0;}main(){for(;scanf("%d%d%d%d",d,d+1,d+2,d+3),f=*d;)y(3,0,0,3)||puts("0");} | ^~~~ main.c: In function 'main': main.c:1:376: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 1 | d[4],e[9],f,k;char s[30];z(){int b,c,a=e[f++];a>9?s[k++]=40,b=z(),s[k++]=a,c=z(),s[k++]=41,a=a-43?a-45?b*c:b-c:b+c:(s[k++]=a+48);return a;}y(o,n,i,j){if(i==7){f=k=0;if(z()==10){s[k]=0;puts(s);return 1;}return 0;}if(o)for(;j--;){e[i]="+-*"[];if(y(o-1,n+1,i+1,3))return 1;}if(n|i==6)for(j=4;j--;)if(e[i]=d[j]){d[j]=0;if(y(o,n-1,i+1,3))return 1;d[j]=e[i];}return 0;}main(){for(;scanf("%d%d%d%d",d,d+1,d+2,d+3),f=*d;)y(3,0,0,3)||puts("0");} | ^~~~~ main.c:1:376: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:1:376: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] main.c:1:376: note: include '<stdio.h>' or provide a declaration of 'scanf'
s623551923
p00041
C
#include <stdio.h> int main(void){ int t; while(~scanf("%d",&t)){ if(t<0 || t>=10) return 1; return 0; }
main.c: In function 'main': main.c:9:1: error: expected declaration or statement at end of input 9 | } | ^
s515041246
p00041
C
#include<stdio.h> #include<stdlib.h> #define NG -1 #define TRUE 1 #define FALSE 0 void cal(int a,int b,int c,int d,int *flag); int main(){ int i,j,k,l,no[4],flag; char ans[20]; while(scanf("%d %d %d %d",&no[0],&no[1],&no[2],&no[3])!=EOF){ if(!no[0] && !no[1] && !no[2] && !no[3]) break; flag=FALSE; for(i=0;i<4;i++){ for(j=0;j<4;j++){ if(i!=j){ for(k=0;k<4;k++){ if(k!=i && k!=j){ for(l=0;l<4;l++){ cal(no[i],no[j],no[k],no[l],&flag,ans); if(flag==TRUE) break; } } if(flag==TRUE) break; } } if(flag==TRUE) break; } if(flag==TRUE) break; } if(flag==TRUE){ printf("%s\n",ans); continue; } printf("0\n"); } return 0; } void cal(int a,int b,int c,int d,int *flag,char *tmp){ int i,j,k,tmp1,tmp2,tmp3; char op[3]={'+','-','*'}; for(i=0;i<3;i++){ switch(i){ case 0: tmp1=a+b; break; case 1: tmp1=a-b; break; case 2: tmp1=a*b; } for(j=0;j<3;j++){ switch(j){ case 0: tmp2=tmp1+c; break; case 1: tmp2=tmp1-c; break; case 2: tmp2=tmp1*c; } for(k=0;k<3;k++){ switch(k){ case 0: tmp3=tmp2+d; break; case 1: tmp3=tmp2-d; break; case 2: tmp3=tmp2*d; } if(tmp3==10){ sprintf(tmp,"(((%d%c%d)%c%d)%c%d)",a,op[i],b,op[j],c,op[k],d); *flag=TRUE; return; } } } } for(i=0;i<3;i++){ switch(i){ case 0: tmp1=a+b; break; case 1: tmp1=a-b; break; case 2: tmp1=a*b; } for(j=0;j<3;j++){ switch(j){ case 0: tmp2=c+d; break; case 1: tmp2=c-d; break; case 2: tmp2=c*d; } for(k=0;k<3;k++){ switch(k){ case 0: tmp3=tmp1+tmp2; break; case 1: tmp3=tmp1-tmp2; break; case 2: tmp3=tmp1*tmp2; } if(tmp3==10){ sprintf(tmp,"((%d%c%d)%c(%d%c%d))",a,op[i],b,op[k],c,op[j],d); *flag=TRUE; return; } } } } *flag=FALSE; sprintf(tmp,"NG"); return; }
main.c: In function 'main': main.c:24:65: error: too many arguments to function 'cal' 24 | cal(no[i],no[j],no[k],no[l],&flag,ans); | ^~~ main.c:8:6: note: declared here 8 | void cal(int a,int b,int c,int d,int *flag); | ^~~ main.c: At top level: main.c:50:6: error: conflicting types for 'cal'; have 'void(int, int, int, int, int *, char *)' 50 | void cal(int a,int b,int c,int d,int *flag,char *tmp){ | ^~~ main.c:8:6: note: previous declaration of 'cal' with type 'void(int, int, int, int, int *)' 8 | void cal(int a,int b,int c,int d,int *flag); | ^~~
s436001107
p00041
C
main(a){for(;++a<2e5;)printf("(");for(;gets(&a),*a%16;)puts(&a);}
main.c:1:1: error: return type defaults to 'int' [-Wimplicit-int] 1 | main(a){for(;++a<2e5;)printf("(");for(;gets(&a),*a%16;)puts(&a);} | ^~~~ main.c: In function 'main': main.c:1:1: error: type of 'a' defaults to 'int' [-Wimplicit-int] main.c:1:23: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 1 | main(a){for(;++a<2e5;)printf("(");for(;gets(&a),*a%16;)puts(&a);} | ^~~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'printf' +++ |+#include <stdio.h> 1 | main(a){for(;++a<2e5;)printf("(");for(;gets(&a),*a%16;)puts(&a);} main.c:1:23: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] 1 | main(a){for(;++a<2e5;)printf("(");for(;gets(&a),*a%16;)puts(&a);} | ^~~~~~ main.c:1:23: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:1:40: error: implicit declaration of function 'gets' [-Wimplicit-function-declaration] 1 | main(a){for(;++a<2e5;)printf("(");for(;gets(&a),*a%16;)puts(&a);} | ^~~~ main.c:1:49: error: invalid type argument of unary '*' (have 'int') 1 | main(a){for(;++a<2e5;)printf("(");for(;gets(&a),*a%16;)puts(&a);} | ^~ main.c:1:56: error: implicit declaration of function 'puts' [-Wimplicit-function-declaration] 1 | main(a){for(;++a<2e5;)printf("(");for(;gets(&a),*a%16;)puts(&a);} | ^~~~ main.c:1:56: note: include '<stdio.h>' or provide a declaration of 'puts' main.c:1:61: error: passing argument 1 of 'puts' from incompatible pointer type [-Wincompatible-pointer-types] 1 | main(a){for(;++a<2e5;)printf("(");for(;gets(&a),*a%16;)puts(&a);} | ^~ | | | int * main.c:1:61: note: expected 'const char *' but argument is of type 'int *'
s153750227
p00041
C
int main(){ while(true){} return 0; }
main.c: In function 'main': main.c:2:7: error: 'true' undeclared (first use in this function) 2 | while(true){} | ^~~~ main.c:1:1: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' +++ |+#include <stdbool.h> 1 | int main(){ main.c:2:7: note: each undeclared identifier is reported only once for each function it appears in 2 | while(true){} | ^~~~
s127585720
p00041
C
int main(void){ while(true); return 0; }
main.c: In function 'main': main.c:2:7: error: 'true' undeclared (first use in this function) 2 | while(true); | ^~~~ main.c:1:1: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' +++ |+#include <stdbool.h> 1 | int main(void){ main.c:2:7: note: each undeclared identifier is reported only once for each function it appears in 2 | while(true); | ^~~~
s713572594
p00041
C++
#!ruby -pal exit if$_[0]==?0 t=[?+,?-,?*] $_=$F.permutation(4).to_a.product(t.product(t,t),[1,2,3].product([1,2])).map{|a,b,c|c.inject(a.zip(b).flatten){|s,r|r*=2;s[r-2..r]=?(+s[r-2..r]*""+?);s}*""}.find{|i|eval(i)==10}||0
a.cc:1:2: error: invalid preprocessing directive #! 1 | #!ruby -pal | ^ a.cc:4:126: error: too many decimal points in number 4 | $_=$F.permutation(4).to_a.product(t.product(t,t),[1,2,3].product([1,2])).map{|a,b,c|c.inject(a.zip(b).flatten){|s,r|r*=2;s[r-2..r]=?(+s[r-2..r]*""+?);s}*""}.find{|i|eval(i)==10}||0 | ^~~~ a.cc:4:139: error: too many decimal points in number 4 | $_=$F.permutation(4).to_a.product(t.product(t,t),[1,2,3].product([1,2])).map{|a,b,c|c.inject(a.zip(b).flatten){|s,r|r*=2;s[r-2..r]=?(+s[r-2..r]*""+?);s}*""}.find{|i|eval(i)==10}||0 | ^~~~ a.cc:2:1: error: 'exit' does not name a type 2 | exit if$_[0]==?0 | ^~~~ a.cc:1:1: note: 'exit' is defined in header '<cstdlib>'; this is probably fixable by adding '#include <cstdlib>' +++ |+#include <cstdlib> 1 | #!ruby -pal a.cc:4:157: error: expected unqualified-id before '.' token 4 | $_=$F.permutation(4).to_a.product(t.product(t,t),[1,2,3].product([1,2])).map{|a,b,c|c.inject(a.zip(b).flatten){|s,r|r*=2;s[r-2..r]=?(+s[r-2..r]*""+?);s}*""}.find{|i|eval(i)==10}||0 | ^ a.cc:4:178: error: expected unqualified-id before '||' token 4 | $_=$F.permutation(4).to_a.product(t.product(t,t),[1,2,3].product([1,2])).map{|a,b,c|c.inject(a.zip(b).flatten){|s,r|r*=2;s[r-2..r]=?(+s[r-2..r]*""+?);s}*""}.find{|i|eval(i)==10}||0 | ^~
s979737829
p00041
C++
#include <iostream> #include <string> #include <sstream> #include <algorithm> using namespace std; #define rep(i,n) for(int i=0; i<(n); ++i) const string op = "+-*"; string S(int x) { stringstream ss; ss << x; return ss.str(); } int calc(int a, char op, int b) { if (op == '+') return a + b; if (op == '-') return a - b; return a * b; } string solve(vector<int> a) { sort(a.begin(), a.end()); do { rep(i,3) rep(j,3) rep(k,3) { if (calc(calc(calc(a[0], op[i], a[1]), op[j], a[2]), op[k], a[3]) == 10) { return "((" + S(a[0]) + " " + op[i] + " " + S(a[1]) + ")" + " " + op[j] + " " + S(a[2]) + ")" + " " + op[k] + " " + S(a[3]); } if (calc(calc(a[0], op[i], a[1]), op[j], calc(a[2], op[k], a[3])) == 10) { return "(" + S(a[0]) + " " + op[i] + " " + S(a[1]) + ")" + " " + op[j] + " " + "(" + S(a[2]) + " " + op[k] + " " + S(a[3]) + ")"; } } } while (next_permutation(a.begin(), a.end())); return "0"; } int main() { vector<int> a(4); while (cin >> a[0] >> a[1] >> a[2] >> a[3], a[0]) { cout << solve(a) << endl; } return 0; }
a.cc:22:14: error: 'vector' was not declared in this scope 22 | string solve(vector<int> a) { | ^~~~~~ a.cc:5:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>' 4 | #include <algorithm> +++ |+#include <vector> 5 | using namespace std; a.cc:22:21: error: expected primary-expression before 'int' 22 | string solve(vector<int> a) { | ^~~ a.cc:22:29: error: expected ',' or ';' before '{' token 22 | string solve(vector<int> a) { | ^ a.cc: In function 'int main()': a.cc:38:5: error: 'vector' was not declared in this scope 38 | vector<int> a(4); | ^~~~~~ a.cc:38:5: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>' a.cc:38:12: error: expected primary-expression before 'int' 38 | vector<int> a(4); | ^~~ a.cc:39:19: error: 'a' was not declared in this scope 39 | while (cin >> a[0] >> a[1] >> a[2] >> a[3], a[0]) { | ^
s647528272
p00041
C++
#include <iostream> using namespace std; char ans[1024]; int number[4]; int usednum[4]; int num[4]; int ope[3]; int solve(int c, int o); int check(); void makeEx(); int main() { int i, count = 0; while (1) { memset(usednum, 0, sizeof(usednum)); for (i = 0; i < 4; i++) { cin >> number[i]; if (number[i] == 0) count++; } if (count == 4) break; solve(0, 0); cout << ans << endl; } return 0; } int solve(int c, int o) { int i; if (c == 4 && o == 3) { if (check()) { return 1; } } else { if (c - o == 1) { for (i = 0; i < 3; i++) { ope[o] = i; if (solve(c, o + 1)) return 1; } } else { for (i = 0; i < 4; i++) { if (!usednum[i]) { num[c] = number[i]; usednum[i] = 1; if (solve(c + 1, o)) return 1; usednum[i] = 0; } } } } return 0; } int check() { int ans, i; for (ans = num[0], i = 0; i < 3; i++) { switch (ope[i]) { case 0: ans += num[i+1]; break; case 1: ans -= num[i+1]; break; case 2: ans *= num[i+1]; break; } } if (ans == 10) { makeEx(); return 1; } return 0; } void makeEx() { int i = 0, j = 0, k = 0, kakko = -1; if ((ope[0] != 2 && (ope[1] == 2 || ope[2] == 2)) || (ope[0] == 2 && ope[1] != 2 && ope[2] == 2)) { ans[i++] = '('; if (ope[1] == 2) kakko = 6; else { kakko = 10; } } while (j != 4 || k != 3) { if (i == kakko) { ans[i++] = ')'; continue; } if (((kakko != -1 && i >= 2) || (kakko == -1 && i >= 1)) && (j != 4 || k != 3)) ans[i++] = ' '; if (j <= k) { ans[i++] = num[j++] + '0'; } else { switch (ope[k++]) { case 0: ans[i] = '+'; break; case 1: ans[i] = '-'; break; case 2: ans[i] = '*'; break; } i++; } } ans[i] = '\0'; }
a.cc: In function 'int main()': a.cc:19:17: error: 'memset' was not declared in this scope 19 | memset(usednum, 0, sizeof(usednum)); | ^~~~~~ a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include <iostream> +++ |+#include <cstring> 2 | using namespace std;
s397261929
p00041
C++
#include <iostream> #include <cstdio> using namespace std; char ans[1024]; int number[4]; int usednum[4]; int num[4]; int ope[3]; int solve(int c, int o); int check(); void makeEx(); int main() { int i, count = 0; while (1) { memset(usednum, 0, sizeof(usednum)); for (i = 0; i < 4; i++) { cin >> number[i]; if (number[i] == 0) count++; } if (count == 4) break; if (solve(0, 0)) cout << ans << endl; else cout << "0" << endl; } return 0; } int solve(int c, int o) { int i; if (c == 4 && o == 3) { if (check()) { return 1; } } else { if (c - o == 1) { for (i = 0; i < 3; i++) { ope[o] = i; if (solve(c, o + 1)) return 1; } } else { for (i = 0; i < 4; i++) { if (!usednum[i]) { num[c] = number[i]; usednum[i] = 1; if (solve(c + 1, o)) return 1; usednum[i] = 0; } } } } return 0; } int check() { int ans, i; for (ans = num[0], i = 0; i < 3; i++) { switch (ope[i]) { case 0: ans += num[i+1]; break; case 1: ans -= num[i+1]; break; case 2: ans *= num[i+1]; break; } } if (ans == 10) { makeEx(); return 1; } return 0; } void makeEx() { int i = 0, j = 0, k = 0, kakko = -1; if ((ope[0] != 2 && (ope[1] == 2 || ope[2] == 2)) || (ope[0] == 2 && ope[1] != 2 && ope[2] == 2)) { ans[i++] = '('; if (ope[1] == 2) kakko = 6; else { kakko = 10; } } while (j != 4 || k != 3) { if (i == kakko) { ans[i++] = ')'; continue; } if (((kakko != -1 && i >= 2) || (kakko == -1 && i >= 1)) && (j != 4 || k != 3)) ans[i++] = ' '; if (j <= k) { ans[i++] = num[j++] + '0'; } else { switch (ope[k++]) { case 0: ans[i] = '+'; break; case 1: ans[i] = '-'; break; case 2: ans[i] = '*'; break; } i++; } } ans[i] = '\0'; }
a.cc: In function 'int main()': a.cc:20:17: error: 'memset' was not declared in this scope 20 | memset(usednum, 0, sizeof(usednum)); | ^~~~~~ a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include <cstdio> +++ |+#include <cstring> 3 | using namespace std;
s419525927
p00041
C++
typedef string::const_iterator State; const string C[5] = {"((a x b) x c) x d", "(a x (b x c)) x d", "a x ((b x c) x d)", "a x (b x (c x d))", "(a x b) x (c x d)"}; const char P[3] = {'+','-','*'}; int term(State &now); int expression(State &now); int fact(State &now); int number(State &now); string solve(int a,int b,int c,int d){ for(int i = 0; i < 5; i++){ string s = C[i]; s[s.find("a")] = '0' + a; s[s.find("b")] = '0' + b; s[s.find("c")] = '0' + c; s[s.find("d")] = '0' + d; for(int p1 = 0; p1 < 3; p1++){ for(int p2 = 0; p2 < 3; p2++){ for(int p3 = 0; p3 < 3; p3++){ string s2 = s; s2[s2.find("x")] = P[p1]; s2[s2.find("x")] = P[p2]; s2[s2.find("x")] = P[p3]; string s3 = s2; s3.erase(remove(all(s3),' '),s3.end()); State now = s3.begin(); int ans = expression(now); if(ans == 10) return s2; } } } } return ""; } int main(){ int a = 0,b = 0,c = 0,d = 0; while(scanf("%d %d %d %d",&a,&b,&c,&d),a|b|c|d){ int st[4] = {a,b,c,d}; sort(st,st + 4); bool exist = false; string res; do{ res = solve(st[0],st[1],st[2],st[3]); if(res != ""){ exist = true; break; } }while(next_permutation(st,st + 4)); if(exist){ string r = "(" + res + ")"; cout<<r<<endl; } else puts("0"); } } int term(State &now){ int ret = fact(now); while(true){ if(*now == '*'){ now++; ret *= fact(now); }else break; } return ret; } int expression(State &now){ int ret = term(now); while(true){ if(*now == '+'){ now++; ret += term(now); }else if(*now == '-'){ now++; ret -= term(now); }else break; } return ret; } int fact(State &now){ if(*now == '('){ now++; int ret = expression(now); now++; return ret; }else{ return number(now); } } int number(State &now){ int ret = 0; while('0' <= (*now) && (*now) <= '9'){ ret *= 10; ret += *now - '0'; now++; } return ret; }
a.cc:1:9: error: 'string' does not name a type 1 | typedef string::const_iterator State; | ^~~~~~ a.cc:3:7: error: 'string' does not name a type 3 | const string C[5] = {"((a x b) x c) x d", | ^~~~~~ a.cc:11:10: error: 'State' was not declared in this scope 11 | int term(State &now); | ^~~~~ a.cc:11:17: error: 'now' was not declared in this scope 11 | int term(State &now); | ^~~ a.cc:12:16: error: 'State' was not declared in this scope 12 | int expression(State &now); | ^~~~~ a.cc:12:23: error: 'now' was not declared in this scope 12 | int expression(State &now); | ^~~ a.cc:13:10: error: 'State' was not declared in this scope 13 | int fact(State &now); | ^~~~~ a.cc:13:17: error: 'now' was not declared in this scope 13 | int fact(State &now); | ^~~ a.cc:14:12: error: 'State' was not declared in this scope 14 | int number(State &now); | ^~~~~ a.cc:14:19: error: 'now' was not declared in this scope 14 | int number(State &now); | ^~~ a.cc:16:1: error: 'string' does not name a type 16 | string solve(int a,int b,int c,int d){ | ^~~~~~ a.cc: In function 'int main()': a.cc:44:9: error: 'scanf' was not declared in this scope 44 | while(scanf("%d %d %d %d",&a,&b,&c,&d),a|b|c|d){ | ^~~~~ a.cc:46:5: error: 'sort' was not declared in this scope; did you mean 'short'? 46 | sort(st,st + 4); | ^~~~ | short a.cc:48:5: error: 'string' was not declared in this scope 48 | string res; | ^~~~~~ a.cc:50:7: error: 'res' was not declared in this scope 50 | res = solve(st[0],st[1],st[2],st[3]); | ^~~ a.cc:50:13: error: 'solve' was not declared in this scope 50 | res = solve(st[0],st[1],st[2],st[3]); | ^~~~~ a.cc:55:12: error: 'next_permutation' was not declared in this scope 55 | }while(next_permutation(st,st + 4)); | ^~~~~~~~~~~~~~~~ a.cc:57:13: error: expected ';' before 'r' 57 | string r = "(" + res + ")"; | ^~ | ; a.cc:58:7: error: 'cout' was not declared in this scope 58 | cout<<r<<endl; | ^~~~ a.cc:58:13: error: 'r' was not declared in this scope 58 | cout<<r<<endl; | ^ a.cc:58:16: error: 'endl' was not declared in this scope 58 | cout<<r<<endl; | ^~~~ a.cc:60:10: error: 'puts' was not declared in this scope 60 | else puts("0"); | ^~~~ a.cc: At global scope: a.cc:64:5: error: redefinition of 'int term' 64 | int term(State &now){ | ^~~~ a.cc:11:5: note: 'int term' previously defined here 11 | int term(State &now); | ^~~~ a.cc:64:10: error: 'State' was not declared in this scope 64 | int term(State &now){ | ^~~~~ a.cc:64:17: error: 'now' was not declared in this scope 64 | int term(State &now){ | ^~~ a.cc:75:5: error: redefinition of 'int expression' 75 | int expression(State &now){ | ^~~~~~~~~~ a.cc:12:5: note: 'int expression' previously defined here 12 | int expression(State &now); | ^~~~~~~~~~ a.cc:75:16: error: 'State' was not declared in this scope 75 | int expression(State &now){ | ^~~~~ a.cc:75:23: error: 'now' was not declared in this scope 75 | int expression(State &now){ | ^~~ a.cc:89:5: error: redefinition of 'int fact' 89 | int fact(State &now){ | ^~~~ a.cc:13:5: note: 'int fact' previously defined here 13 | int fact(State &now); | ^~~~ a.cc:89:10: error: 'State' was not declared in this scope 89 | int fact(State &now){ | ^~~~~ a.cc:89:17: error: 'now' was not declared in this scope 89 | int fact(State &now){ | ^~~ a.cc:100:5: error: redefinition of 'int number' 100 | int number(State &now){ | ^~~~~~ a.cc:14:5: note: 'int number' previously defined here 14 | int number(State &now); | ^~~~~~ a.cc:100:12: error: 'State' was not declared in this scope 100 | int number(State &now){ | ^~~~~ a.cc:100:19: error: 'now' was not declared in this scope 100 | int number(State &now){ | ^~~
s530701674
p00041
C++
#include<vector> #include<sstream> using namespace std; string s="true"; string i2s(int n){ stringstream x; x<<n; return x.str(); } bool calc(int a,int b){ if(a+b==10) { s+="+"; return true; } if(a-b==10){ s+="-"; return true; } if(a*b==10) { s+="*"; return true; } return false; } bool calc(int a,int b, int c){ if(calc(a+b,c)) { s+="0+"; return true; } if(calc(a-b,c)) { s+="0-"; return true; } if(calc(a*b,c)) { s+="0*"; return true; } if(calc(a,b+c)) { s+="1+"; return true; } if(calc(a,b-c)) { s+="1-"; return true; }if(calc(a,b*c)) { s+="1*"; return true; } return false; } bool calc(int a,int b, int c, int d){ if(calc(a+b,c,d)) { s+="0+"; return true; } if(calc(a-b,c,d)) { s+="0-"; return true; } if(calc(a*b,c,d)) { s+="0*"; return true; } if(calc(a,b+c,d)) { s+="1+"; return true; } if(calc(a,b-c,d)){ s+="1-"; return true; } if(calc(a,b*c,d)) { s+="1*"; return true; } if(calc(a,b,c+d)) { s+="2+"; return true; } if(calc(a,b,c-d)) { s+="2-"; return true; } if(calc(a,b,c*d)){ s+="2*"; return true; } return false; } int main(){ int a[4]; while(cin>>a[0]>>a[1]>>a[2]>>a[3],a[0]||a[1]||a[2]||a[3]){ int i,j,k,l; int bi,bj,bk,bl; bool f=false; s=""; for(i=0;i<4;i++){ for(j=0;j<4;j++){ for(k=0;k<4;k++){ for(l=0;l<4;l++){ if(i==j||i==k||i==l||j==k||j==l||k==l) continue; if(calc(a[i],a[j],a[k],a[l])){ bi=i;bj=j;bk=k;bl=l; f=true; break; } } if(f) break; } if(f) break; } if(f) break; } if(f){ //cout << s << endl; //cout << a[bi] << a[bj] << a[bk] << a[bl] << endl; vector<string> b; b.push_back(i2s(a[bi]));b.push_back(i2s(a[bj])); b.push_back(i2s(a[bk]));b.push_back(i2s(a[bl])); string o=""; o+="("; o+=(b[s[3]-'0']); o+=s[4]; o+=(b[s[3]-'0'+1]); o+=")"; b[s[3]-'0']=o; b.erase(b.begin()+(s[3]-'0')+1); o=""; o+="("; o+=(b[s[1]-'0']); o+=s[2]; o+=(b[s[1]-'0'+1]); o+=")"; b[s[1]-'0']=o; b.erase(b.begin()+(s[1]-'0')+1); o=""; o+="("; o+=(b[0]); o+=s[0]; o+=(b[1]); o+=")"; b[0]=o; b.erase(b.begin()+1); cout << b[0] << endl; } else cout << 0 << endl; } return 0; }
a.cc: In function 'int main()': a.cc:96:9: error: 'cin' was not declared in this scope 96 | while(cin>>a[0]>>a[1]>>a[2]>>a[3],a[0]||a[1]||a[2]||a[3]){ | ^~~ a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 2 | #include<sstream> +++ |+#include <iostream> 3 | using namespace std; a.cc:149:7: error: 'cout' was not declared in this scope 149 | cout << b[0] << endl; | ^~~~ a.cc:149:7: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:151:10: error: 'cout' was not declared in this scope 151 | else cout << 0 << endl; | ^~~~ a.cc:151:10: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
s581821991
p00041
C++
#include<bits/stdc++.h> #include<vector> #include<list> #include<stack> #include<queue> #include<algorithm> #include<map> #include<cmath> #include<complex> using namespace std; typedef complex<double> P; #define X real() #define Y imag() int d[4]; bool f=0; const char *op="+-*"; int cal(int a,int o,int b){ if(o==0) return a+b; if(o==1) return a-b; return a*b; } bool sol(int a,int b,int c) { f++; if (cal(cal(cal(d[0],a,d[1]),b,d[2]),c,d[3])==10) { printf("(((%d %c %d) %c %d) %c %d)\n",d[0],op[a],d[1],op[b],d[2],op[c],d[3]); return true; } if (cal(cal(d[0],a,d[1]),b, cal(d[2],c,d[3]))==10) { printf("((%d %c %d) %c (%d %c %d))\n",d[0],op[a],d[1],op[b],d[2],op[c],d[3]); reeturn true; } if (cal(cal(d[0],a, cal(d[1],b,d[2])),c,d[3])==10) { printf("((%d %c (%d %c %d)) %c %d)\n",d[0],op[a],d[1],op[b],d[2],op[c],d[3]); return true; } return f=0; } bool jg() { for (int i=0;i<3;++i) { for (int j=0;j<3;++j) { for (int k=0;k<3;++k) { if (sol(i,j,k)) return true; } } } } int main(){ int mod=1000000007; for (;;) { scanf("%d %d %d %d",&d[0],&d[1],&d[2],&d[3]); if (d[0]==d[1] && d[1]==d[2] && d[2]==d[3] && d[0]==0) break; sort(d,d+4); do { if (jg()) break; } while (next_permutation(d,d+4)); if (f==0) printf("0\n"); } return 0; }
a.cc: In function 'bool sol(int, int, int)': a.cc:27:5: error: use of an operand of type 'bool' in 'operator++' is forbidden in C++17 27 | f++; | ^ a.cc:34:9: error: 'reeturn' was not declared in this scope 34 | reeturn true; | ^~~~~~~ a.cc: In function 'bool jg()': a.cc:51:1: warning: control reaches end of non-void function [-Wreturn-type] 51 | } | ^
s982893960
p00041
C++
#include<iostream> #include<stack> #include<string> const int N = 4; const char *oprs = "+-*"; int operands[N]; int bExist = false; using namespace std; int generateExpression(int *oprpos, int *opr, int *operand, int n, int *e){ int t = 0; int eIndex = 0; int nextOperand = 0; e[eIndex++] = operands[operand[nextOperand++]]; e[eIndex++] = operands[operand[nextOperand++]]; for(int i = 0; i < n - 1; i++){ for(int j = t; j < oprpos[i] + t; j++){ e[eIndex++] = oprs[opr[j]]; } if( i < n - 2 ){ e[eIndex++] = operands[operand[nextOperand++]]; } t += oprpos[i]; } return eIndex; } int calculateExpression( int *e, int esize, string &answer ){ int i = 0; stack< int > st; stack< string > sst; int ret = 0; for(int i = 0; i < esize; i++){ int t, t1, t2; string exp, exp1, exp2; char opr; opr = e[i]; if( opr == '+' || opr == '-' || opr == '*' ){ exp1 = sst.top(); sst.pop(); exp2 = sst.top(); sst.pop(); switch( opr ){ case '+': t1 = st.top(); st.pop(); t2 = st.top(); st.pop(); t = t1 + t2; st.push( t ); break; case '-': t2 = st.top(); st.pop(); t1 = st.top(); st.pop(); swap( exp1, exp2 ); t = t1 - t2; st.push( t ); break; case '*': t1 = st.top(); st.pop(); t2 = st.top(); st.pop(); t = t1 * t2; st.push( t ); break; } exp = '(';exp+=exp1;exp+=' ';exp+=opr;exp+=' ';exp+=exp2;exp+=')'; sst.push( exp ); }else{ char stroperand[32]; itoa( opr, stroperand, 10 ); st.push( opr ); sst.push( stroperand ); } } ret = st.top(); answer = sst.top(); return ret; } void permit_operand(int *flag, int *p, int rest, int n, int *opr, int *oprpos){ int t = 0; for(int i = 0; i < n; i++ ){ if( flag[i] ){ t++; } } if( t == n ){ // TODO int e[N*2], esize; string expr; esize = generateExpression( oprpos, opr, p, n, e); if( calculateExpression( e, esize, expr ) == 10 ){ if( !bExist ){ bExist = true; cout << expr << '\n'; } } return ; } for(int i = 0; i < n; i++ ){ if( flag[i] ){ continue; }else{ flag[i] = 1; p[n - rest] = i; permit_operand(flag, p, rest - 1, n, opr, oprpos); flag[i] = 0; } } } void rawcomb_opr(int *p, int rest, int n, int *oprpos){ if( rest == 0 ){ // TODO int flag[N] = {0,}; int operand[N]; permit_operand( flag, operand, N, N, p, oprpos ); return ; } for(int i = 0; i < n; i++){ p[n - rest] = i; rawcomb_opr(p, rest - 1, n, oprpos); } } void rawcomb_oprpos(int *p, int rest, int n){ if( rest == 0 ){ // TODO int t = 0; for(int m = 0; m < n - 1; m++){ t += p[m]; if( t > m + 1 ){ return ; } } if( t == n - 1 ){ int opr[N]; rawcomb_opr( opr, 3, 3, p ); } return ; } for(int i = 0; i < n + 1 - rest; i++){ p[(n - 1) - rest] = i; rawcomb_oprpos(p, rest - 1, n); } } int main(void){ while(true){ int end = 0; int p[N]; for(int i = 0; i < N; i++){ cin>>operands[i]; end |= operands[i]; } if( end == 0 ){ break; } bExist = false; rawcomb_oprpos(p, N - 1, N); if( !bExist ){ cout << "0\n"; } } return 0; }
a.cc: In function 'int calculateExpression(int*, int, std::string&)': a.cc:71:25: error: 'itoa' was not declared in this scope 71 | itoa( opr, stroperand, 10 ); | ^~~~
s871325112
p00041
C++
#include<iostream> #include<cstdlib> #include<stack> #include<string> const int N = 4; const char *oprs = "+-*"; int operands[N]; int bExist = false; using namespace std; int generateExpression(int *oprpos, int *opr, int *operand, int n, int *e){ int t = 0; int eIndex = 0; int nextOperand = 0; e[eIndex++] = operands[operand[nextOperand++]]; e[eIndex++] = operands[operand[nextOperand++]]; for(int i = 0; i < n - 1; i++){ for(int j = t; j < oprpos[i] + t; j++){ e[eIndex++] = oprs[opr[j]]; } if( i < n - 2 ){ e[eIndex++] = operands[operand[nextOperand++]]; } t += oprpos[i]; } return eIndex; } int calculateExpression( int *e, int esize, string &answer ){ int i = 0; stack< int > st; stack< string > sst; int ret = 0; for(int i = 0; i < esize; i++){ int t, t1, t2; string exp, exp1, exp2; char opr; opr = e[i]; if( opr == '+' || opr == '-' || opr == '*' ){ exp1 = sst.top(); sst.pop(); exp2 = sst.top(); sst.pop(); switch( opr ){ case '+': t1 = st.top(); st.pop(); t2 = st.top(); st.pop(); t = t1 + t2; st.push( t ); break; case '-': t2 = st.top(); st.pop(); t1 = st.top(); st.pop(); swap( exp1, exp2 ); t = t1 - t2; st.push( t ); break; case '*': t1 = st.top(); st.pop(); t2 = st.top(); st.pop(); t = t1 * t2; st.push( t ); break; } exp = '(';exp+=exp1;exp+=' ';exp+=opr;exp+=' ';exp+=exp2;exp+=')'; sst.push( exp ); }else{ char stroperand[32]; _itoa( opr, stroperand, 10 ); st.push( opr ); sst.push( stroperand ); } } ret = st.top(); answer = sst.top(); return ret; } void permit_operand(int *flag, int *p, int rest, int n, int *opr, int *oprpos){ int t = 0; for(int i = 0; i < n; i++ ){ if( flag[i] ){ t++; } } if( t == n ){ // TODO int e[N*2], esize; string expr; esize = generateExpression( oprpos, opr, p, n, e); if( calculateExpression( e, esize, expr ) == 10 ){ if( !bExist ){ bExist = true; cout << expr << '\n'; } } return ; } for(int i = 0; i < n; i++ ){ if( flag[i] ){ continue; }else{ flag[i] = 1; p[n - rest] = i; permit_operand(flag, p, rest - 1, n, opr, oprpos); flag[i] = 0; } } } void rawcomb_opr(int *p, int rest, int n, int *oprpos){ if( rest == 0 ){ // TODO int flag[N] = {0,}; int operand[N]; permit_operand( flag, operand, N, N, p, oprpos ); return ; } for(int i = 0; i < n; i++){ p[n - rest] = i; rawcomb_opr(p, rest - 1, n, oprpos); } } void rawcomb_oprpos(int *p, int rest, int n){ if( rest == 0 ){ // TODO int t = 0; for(int m = 0; m < n - 1; m++){ t += p[m]; if( t > m + 1 ){ return ; } } if( t == n - 1 ){ int opr[N]; rawcomb_opr( opr, 3, 3, p ); } return ; } for(int i = 0; i < n + 1 - rest; i++){ p[(n - 1) - rest] = i; rawcomb_oprpos(p, rest - 1, n); } } int main(void){ while(true){ int end = 0; int p[N]; for(int i = 0; i < N; i++){ cin>>operands[i]; end |= operands[i]; } if( end == 0 ){ break; } bExist = false; rawcomb_oprpos(p, N - 1, N); if( !bExist ){ cout << "0\n"; } } return 0; }
a.cc: In function 'int calculateExpression(int*, int, std::string&)': a.cc:72:25: error: '_itoa' was not declared in this scope 72 | _itoa( opr, stroperand, 10 ); | ^~~~~
s153074982
p00041
C++
#include <iostream> #include <sstream> #include <iomanip> #include <algorithm> #include <cmath> #include <string> #include <vector> #include <list> #include <queue> #include <stack> #include <set> #include <map> #include <bitset> #include <numeric> #include <climits> #include <cfloat> using namespace std; int ope(int a, int b, int i){ if(i == 0) return a + b; else if(i == 1) return a - b; else return a * b; } void solve(vector<int> a) { char c[] = {'+', '-', '*'}; sort(a.begin(), a.end()); do{ for(int i=0; i<27; ++i){ int b1 = i % 3; int b2 = i / 3 % 3; int b3 = i / 9; if(ope(ope(a[0], a[1], b1), ope(a[2], a[3], b2), b3) == 10){ cout << "((" << a[0] << c[i] << a[1] << ')' << c[k] << '(' << a[2] << c[j] << a[3] << "))" << endl; return; } if(ope(ope(ope(a[0], a[1], b1), a[2], b2), a[3], b3) == 10){ cout << "(((" << a[0] << c[i] << a[1] << ')' << c[j] << a[2] << ')' << c[k] << a[3] << ')' << endl; return; } if(ope(ope(a[0], ope(a[1], a[2], b1), b2), a[3], b3) == 10){ cout << "((" << a[0] << c[j] << '(' << a[1] << c[i] << a[2] << "))" << c[k] << a[3] << ')' << endl; return; } } }while(next_permutation(a.begin(), a.end())); cout << '0' << endl; } int main() { for(;;){ vector<int> a(4); for(int i=0; i<4; ++i){ cin >> a[i]; if(a[i] == 0) return 0; } solve(a); } }
a.cc: In function 'void solve(std::vector<int>)': a.cc:39:66: error: 'k' was not declared in this scope 39 | cout << "((" << a[0] << c[i] << a[1] << ')' << c[k] << '(' << a[2] << c[j] << a[3] << "))" << endl; | ^ a.cc:39:89: error: 'j' was not declared in this scope 39 | cout << "((" << a[0] << c[i] << a[1] << ')' << c[k] << '(' << a[2] << c[j] << a[3] << "))" << endl; | ^ a.cc:43:67: error: 'j' was not declared in this scope 43 | cout << "(((" << a[0] << c[i] << a[1] << ')' << c[j] << a[2] << ')' << c[k] << a[3] << ')' << endl; | ^ a.cc:43:90: error: 'k' was not declared in this scope 43 | cout << "(((" << a[0] << c[i] << a[1] << ')' << c[j] << a[2] << ')' << c[k] << a[3] << ')' << endl; | ^ a.cc:47:43: error: 'j' was not declared in this scope 47 | cout << "((" << a[0] << c[j] << '(' << a[1] << c[i] << a[2] << "))" << c[k] << a[3] << ')' << endl; | ^ a.cc:47:90: error: 'k' was not declared in this scope 47 | cout << "((" << a[0] << c[j] << '(' << a[1] << c[i] << a[2] << "))" << c[k] << a[3] << ')' << endl; | ^
s571618104
p00041
C++
#include<stdio.h> #include<ctype.h> #include<vector> #include<string> #include<algorithm> using namespace std; typedef vector<char>V; int a[4]; string P(V&v,int&i) { int f=isdigit(v[i]); string s; s+=v[i--]; if(!f) { s+=" "+P(v,i)+')'; s='('+P(v,i)+' '+s; } return s; } int F(V v,int i,int n) { if(v.size()-7) { char*p,s[9]={},f=0; p=s; if(i<4)*s=a[i]+'0'; if(n>1)strcat(s,"+-*"); for(p=s;*p;++p) { V t(v); t.push_back(*p); if(isdigit(*p))f=F(t,i+1,n+1); else f=F(t,i,n-1); if(f)return 1; } } else { int x[4],c; for(n=i=0;i<7;++i) { if(isdigit(c=v[i]))x[n++]=v[i]-'0'; else { int l=x[n-2],r=x[n-1],t; if(c=='+')t=l+r; if(c=='-')t=l-r; if(c=='*')t=l*r; x[n-2]=t; --n; } } if(*x==10) { puts(P(v,i=6).c_str()); return 1; } } return 0; } int main() { for(;;) { int i,f; for(f=i=0;i<4;++i)if(scanf("%d",a+i),!a[i])return 0; sort(a,a+4); do { f=F(V(),0,0); if(f)break; }while(next_permutation(a,a+4)); if(!f)puts("0"); } }
a.cc: In function 'int F(V, int, int)': a.cc:28:24: error: 'strcat' was not declared in this scope 28 | if(n>1)strcat(s,"+-*"); | ^~~~~~ a.cc:6:1: note: 'strcat' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 5 | #include<algorithm> +++ |+#include <cstring> 6 | using namespace std;
s860946998
p00041
C++
#include<iostream> #include<cstdio> using namespace std; char conv(int o) { if(o==0) return '+'; if(o==1) return '-'; if(o==2) return '*'; } int calc(int m,int n,int o) { if(o==0) return m+n; if(o==1) return m-n; if(o==2) return m*n; } int main() { int nums[4]; while(cin>>nums[0]>>nums[1]>>nums[2]>>nums[3],nums[0]) { bool flag=false; do { int o1=0,o2=0,o3=-1; for(int i = 0; i < 27; ++i) { o3++; if (o3==3) { o3=0; o2++; if (o2==3) { o1++; o2=0; } } if( calc(calc(nums[0],nums[1],o1),calc(nums[2],nums[3],o3),o2)==10 ) { printf("(%d %c %d) %c (%d %c %d)\n",nums[0],conv(o1),nums[1],conv(o2),nums[2],conv(o3),nums[3]); flag=true; break; } if( calc(calc(calc(nums[0],nums[1],o1),nums[2],o2),nums[3],o3)==10 ) { printf("((%d %c %d) %c %d) %c %d\n",nums[0],conv(o1),nums[1],conv(o2),nums[2],conv(o3),nums[3]); flag=true; break; } if( calc(nums[0],calc(calc(nums[1],nums[2],o2),nums[3],o3),o1)==10 ) { printf("%d %c ((%d %c %d) %c %d)\n",nums[0],conv(o1),nums[1],conv(o2),nums[2],conv(o3),nums[3]); flag=true; break; } if( calc(calc(nums[0],calc(nums[1],nums[2],o2),o1),nums[3],o3)==10 ) { printf("(%d %c (%d %c %d)) %c %d\n",nums[0],conv(o1),nums[1],conv(o2),nums[2],conv(o3),nums[3]); flag=true; break; } if( calc(nums[0],calc(nums[1],calc(nums[2],nums[3],o3),o2),o1)==10 ) { printf("%d %c (%d %c (%d %c %d))\n",nums[0],conv(o1),nums[1],conv(o2),nums[2],conv(o3),nums[3]); flag=true; break; } } } while (!flag&&next_permutation(nums,nums+4)); if(!flag) cout<<0<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:70:33: error: 'next_permutation' was not declared in this scope 70 | } while (!flag&&next_permutation(nums,nums+4)); | ^~~~~~~~~~~~~~~~ a.cc: In function 'char conv(int)': a.cc:10:1: warning: control reaches end of non-void function [-Wreturn-type] 10 | } | ^ a.cc: In function 'int calc(int, int, int)': a.cc:18:1: warning: control reaches end of non-void function [-Wreturn-type] 18 | } | ^
s884746719
p00041
C++
main(a){for(;++a<2e5;)printf("(");for(;gets(&a);)puts(&a);}
a.cc:1:5: error: expected constructor, destructor, or type conversion before '(' token 1 | main(a){for(;++a<2e5;)printf("(");for(;gets(&a);)puts(&a);} | ^
s351263367
p00041
C++
#include <stdio.h> int main(){ int a[4]; for(int i = 0; i < 100000; ++i) putchar('('); while(1){ for(int i = 0; i < 4; ++i){ scanf_s("%d", &a[i]); } if(a[0] == 0){ break; } printf("%d+%d+%d+%d", a[0], a[1], a[2], a[3]); putchar('\n'); } }
a.cc: In function 'int main()': a.cc:8:13: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'? 8 | scanf_s("%d", &a[i]); | ^~~~~~~ | scanf
s898824472
p00041
C++
#include <iostream> #include <algorithm> #include <sstream> #include <string> #include <vector> using namespace std; typedef vector <int> vi; typedef vector <vi> vvi; #define REP(i,n) for (int i=0; i<n; i++) #define I2S(i) to_string(i) vvi permutations(vi x){ vvi buf; int n=x.size(), i=0; sort(x.begin(),x.end()); do{ vi buf0(n); REP(i,n) buf0[i]=x[i]; buf.push_back(buf0); buf0.clear(); }while (next_permutation(x.begin(), x.end())); return buf; } vvi products(vi x, int n){ int n2=x.size(), n3=(int)pow(n2,n); vvi buf(n3); REP(i,n3){ vi buf0(n); int tmp = i; REP(i2,n){ buf0[i2] = x[tmp%n2]; tmp /= n2; } buf[i] = buf0; } return buf; } int op(int x, int y, int mode){ switch (mode){ case 0: return x+y; case 1: return x-y; case 2: return x*y; } } string check(vi x, int n){ int x0=x[0], x1=x[1], x2=x[2], x3=x[3]; string s0=I2S(x[0]), s1=I2S(x[1]), s2=I2S(x[2]), s3=I2S(x[3]); string ops="+-*", eq1, eq2; int n1 = ops.size(); REP(i1, n1){ int a1 = op(x0, x1, i1); eq1 = "("+s0+" "+ops[i1]+" "+s1+")"; REP(i2, n1){ int a2 = op(a1, x2, i2); eq2 = "("+eq1+" "+ops[i2]+" "+s2+")"; REP(i3, n1) if (op(a2, x3, i3)==n) return "("+eq2+" "+ops[i3]+" "+s3+")"; a2 = op(x2, x3, i2); eq2 = "("+s2+" "+ops[i2]+" "+s3+")"; REP(i3,n1) if (op(a1, a2, i3)==n) return "("+eq1+" "+ops[i3]+" "+eq2+")"; } } return ""; } vi getx(){ string line; getline(cin,line); istringstream is(line); vi x; int tmp; bool end = true; while(is>>tmp){ if (tmp!=0) end = false; x.push_back(tmp); } if (end) x.clear(); return x; } int f0041(){ int n=10; while (true){ vi x = getx(); if (x.empty()) return 0; vvi xx = permutations(x); bool f = true; REP(i,(int)xx.size()){ string s = check(xx[i],n); if (s != ""){ cout<<s<<endl; f = false; break; } } if (f) cout<<"0"<<endl; } } int main(void){ f0041(); }
a.cc: In function 'vvi products(vi, int)': a.cc:27:34: error: 'pow' was not declared in this scope 27 | int n2=x.size(), n3=(int)pow(n2,n); | ^~~ a.cc: In function 'int op(int, int, int)': a.cc:50:1: warning: control reaches end of non-void function [-Wreturn-type] 50 | } | ^
s153121216
p00041
C++
#include <iostream> #include <algorithm> #include <sstream> #include <string> #include <vector> using namespace std; typedef vector <int> vi; typedef vector <vi> vvi; #define REP(i,n) for (int i=0; i<n; i++) #define ALL(x) x.begin(), x.end() string i2s(int n) { stringstream ss; ss << n; return ss.str(); } vvi permutations(vi x){ vvi buf; int n=x.size(), i=0; sort(ALL(x)); do{ vi buf0(n); REP(i,n) buf0[i]=x[i]; buf.push_back(buf0); buf0.clear(); }while (next_permutation(ALL(x))); return buf; } vvi products(vi x, int n){ int n2=x.size(), n3=(int)pow(n2,n); vvi buf(n3); REP(i,n3){ vi buf0(n); int tmp = i; REP(i2,n){ buf0[i2] = x[tmp%n2]; tmp /= n2; } buf[i] = buf0; } return buf; } int op(int x, int y, int mode){ switch (mode){ case 0: return x+y; case 1: return x-y; case 2: return x*y; } } string check(vi x, int n){ int x0=x[0], x1=x[1], x2=x[2], x3=x[3]; string s0=i2s(x0), s1=i2s(x1), s2=i2s(x2), s3=i2s(x3); string ops="+-*", eq1, eq2; int n1 = ops.size(); REP(i1, n1){ int a1 = op(x0, x1, i1); eq1 = "("+s0+" "+ops[i1]+" "+s1+")"; REP(i2, n1){ int a2 = op(a1, x2, i2); eq2 = "("+eq1+" "+ops[i2]+" "+s2+")"; REP(i3, n1) if (op(a2, x3, i3)==n) return "("+eq2+" "+ops[i3]+" "+s3+")"; a2 = op(x2, x3, i2); eq2 = "("+s2+" "+ops[i2]+" "+s3+")"; REP(i3,n1) if (op(a1, a2, i3)==n) return "("+eq1+" "+ops[i3]+" "+eq2+")"; } } return ""; } vi getx(){ string line; getline(cin,line); istringstream is(line); vi x; int tmp; bool end = true; while(is>>tmp){ if (tmp!=0) end = false; x.push_back(tmp); } if (end) x.clear(); return x; } int f0041(){ int n=10; while (true){ vi x = getx(); if (x.empty()) return 0; vvi xx = permutations(x); bool f = true; REP(i,(int)xx.size()){ string s = check(xx[i],n); if (s != ""){ cout<<s<<endl; f = false; break; } } if (f) cout<<"0"<<endl; } } int main(void){ f0041(); }
a.cc: In function 'vvi products(vi, int)': a.cc:34:34: error: 'pow' was not declared in this scope 34 | int n2=x.size(), n3=(int)pow(n2,n); | ^~~ a.cc: In function 'int op(int, int, int)': a.cc:57:1: warning: control reaches end of non-void function [-Wreturn-type] 57 | } | ^
s906486941
p00042
Java
#include<iostream> #include<string> #include<algorithm> #include<map> #include<set> #include<utility> #include<vector> #include<cmath> #include<cstdio> #define loop(i,a,b) for(int i=a;i<b;i++) #define rep(i,a) loop(i,0,a) #define pb push_back #define mp make_pair #define it ::iterator #define all(in) in.begin(),in.end() const double PI=acos(-1); const double ESP=1e-10; using namespace std; int main(){ int m; int co=0; while(cin>>m,m){ co++; int n; char d; cin>>n; vector<int>w(n),v(n); vector<vector<int> >dp(n+1); rep(i,m+1)dp[0].pb(0); rep(i,n)cin>>v[i]>>d>>w[i]; rep(i,n){ //dp[i].pb(0); rep(j,m+1){ if(w[i]>j)dp[i+1].pb(dp[i][j]); else dp[i+1].pb(max(dp[i][j],dp[i][j-w[i]]+v[i])); } } int maxi=0; rep(i,m)if(dp[n][i]==dp[n][m]){maxi=i;break;} cout<<"Case "<<co<<":"<<endl; cout<<dp[n][m]<<endl; cout<<maxi<<endl; } }
Main.java:1: error: illegal character: '#' #include<iostream> ^ Main.java:2: error: illegal character: '#' #include<string> ^ Main.java:3: error: illegal character: '#' #include<algorithm> ^ Main.java:4: error: illegal character: '#' #include<map> ^ Main.java:5: error: illegal character: '#' #include<set> ^ Main.java:6: error: illegal character: '#' #include<utility> ^ Main.java:7: error: illegal character: '#' #include<vector> ^ Main.java:8: error: illegal character: '#' #include<cmath> ^ Main.java:9: error: illegal character: '#' #include<cstdio> ^ Main.java:10: error: illegal character: '#' #define loop(i,a,b) for(int i=a;i<b;i++) ^ Main.java:10: error: class, interface, enum, or record expected #define loop(i,a,b) for(int i=a;i<b;i++) ^ Main.java:10: error: class, interface, enum, or record expected #define loop(i,a,b) for(int i=a;i<b;i++) ^ Main.java:11: error: illegal character: '#' #define rep(i,a) loop(i,0,a) ^ Main.java:12: error: illegal character: '#' #define pb push_back ^ Main.java:13: error: illegal character: '#' #define mp make_pair ^ Main.java:14: error: illegal character: '#' #define it ::iterator ^ Main.java:15: error: illegal character: '#' #define all(in) in.begin(),in.end() ^ Main.java:17: error: class, interface, enum, or record expected const double ESP=1e-10; ^ Main.java:18: error: class, interface, enum, or record expected using namespace std; ^ Main.java:22: error: not a statement while(cin>>m,m){ ^ Main.java:26: error: not a statement cin>>n; ^ Main.java:27: error: not a statement vector<int>w(n),v(n); ^ Main.java:28: error: not a statement vector<vector<int> >dp(n+1); ^ Main.java:30: error: not a statement rep(i,n)cin>>v[i]>>d>>w[i]; ^ Main.java:41: error: not a statement cout<<"Case "<<co<<":"<<endl; ^ Main.java:42: error: not a statement cout<<dp[n][m]<<endl; ^ Main.java:43: error: not a statement cout<<maxi<<endl; ^ Main.java:19: error: unnamed classes are a preview feature and are disabled by default. int main(){ ^ (use --enable-preview to enable unnamed classes) Main.java:22: error: ')' expected while(cin>>m,m){ ^ Main.java:22: error: ';' expected while(cin>>m,m){ ^ Main.java:27: error: ';' expected vector<int>w(n),v(n); ^ Main.java:27: error: ';' expected vector<int>w(n),v(n); ^ Main.java:28: error: ';' expected vector<vector<int> >dp(n+1); ^ Main.java:28: error: ';' expected vector<vector<int> >dp(n+1); ^ Main.java:29: error: ';' expected rep(i,m+1)dp[0].pb(0); ^ Main.java:30: error: ';' expected rep(i,n)cin>>v[i]>>d>>w[i]; ^ Main.java:31: error: ';' expected rep(i,n){ ^ Main.java:33: error: ';' expected rep(j,m+1){ ^ Main.java:39: error: ';' expected rep(i,m)if(dp[n][i]==dp[n][m]){maxi=i;break;} ^ 39 errors
s146777043
p00042
Java
import java.io.*; import java.util.StringTokenizer; class Item { int cost,weight; Item(int c,int w) { this.cost = c; this.weight = w; } } class Main { private static final int NOT_ADD = -1; public static void main (String args[]) { InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); String buf; try { long long count = 1; while (true) { int W = Integer.parseInt(br.readLine()); if (W==0) break; int N = Integer.parseInt(br.readLine()); Item item[] = new Item[N]; for (int i=0;i<N;i++) { StringTokenizer st = new StringTokenizer(br.readLine(),","); int c = Integer.parseInt(st.nextToken()); int w = Integer.parseInt(st.nextToken()); item[i] = new Item(c,w); } int T[][] = new int[N][W+1]; for (int i=0;i<N;i++) { for (int j=0;j<=W;j++) T[i][j] = NOT_ADD; } T[0][0] = 0; T[0][item[0].weight] = item[0].cost; for (int i=1;i<N;i++) { for (int k=0;k<=W;k++) T[i][k] = T[i-1][k]; for (int k=item[i].weight;k<=W;k++) { if (T[i-1][k-item[i].weight]!=NOT_ADD&&T[i-1][k-item[i].weight]+item[i].cost>T[i][k]) { T[i][k] = T[i-1][k-item[i].weight]+item[i].cost; } else if (T[i-1][k-item[i].weight]==NOT_ADD) { T[i][k] = item[i].cost; } } } int MaxCost = T[N-1][0]; int MaxWeight = 0; for (int i=0;i<=W;i++) { if (MaxCost<T[N-1][i]) { MaxCost = T[N-1][i]; MaxWeight = i; } } System.out.println("Case "+count+":"); System.out.println((long)MaxCost); System.out.println(MaxWeight); count++; } } catch (Exception e) { e.printStackTrace(); } } }
Main.java:22: error: not a statement long long count = 1; ^ Main.java:22: error: ';' expected long long count = 1; ^ 2 errors
s139313587
p00042
Java
import java.io.*; class Main{ public static void main(String[] args) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String line=""; int count=1; while(!(line=br.readLine()).equals("0")){ int weight=0; static int W=Integer.parseInt(line); static int n=Integer.parseInt(br.readLine()); static int[] v=new int[n]; static int[] w=new int[n]; static int[][] dp=new int[n+1][W+1]; static boolean[] use=new boolean[n]; for(int i=0;i<n;i++){ String[] str=br.readLine().split(","); v[i]=Integer.parseInt(str[0]); w[i]=Integer.parseInt(str[1]); } System.out.println("Case "+count+":"); System.out.println(MaxValue(0,W)); for(int i=0;i<n;i++){ if(use[i]){ weight+=w[i]; } System.out.println(weigght); } } private static int MaxValue(int i,int j){ if(dp[i][j]!=0){ return dp[i][j]; } else if(i==n){ return 0; } else if(j>w[i]){ use[i]=false; return dp[i][j]=MaxValue(i+1,j); } else{ int p=MaxValue(i+1,j); int q=MaxValue(i+1,j-w[i])+v[i]; int r=Math.max(MaxValue(i+1,j),MaxValue(i+1,j-w[i])+v[i]); use[i]=(p==r)?false:true; return dp[i][j]=r; } } }
Main.java:10: error: illegal start of expression static int W=Integer.parseInt(line); ^ Main.java:16: error: illegal start of type for(int i=0;i<n;i++){ ^ Main.java:16: error: > or ',' expected for(int i=0;i<n;i++){ ^ Main.java:16: error: <identifier> expected for(int i=0;i<n;i++){ ^ Main.java:21: error: <identifier> expected System.out.println("Case "+count+":"); ^ Main.java:21: error: illegal start of type System.out.println("Case "+count+":"); ^ Main.java:22: error: <identifier> expected System.out.println(MaxValue(0,W)); ^ Main.java:22: error: <identifier> expected System.out.println(MaxValue(0,W)); ^ Main.java:23: error: illegal start of type for(int i=0;i<n;i++){ ^ Main.java:23: error: > or ',' expected for(int i=0;i<n;i++){ ^ Main.java:23: error: <identifier> expected for(int i=0;i<n;i++){ ^ Main.java:30: error: unnamed classes are a preview feature and are disabled by default. private static int MaxValue(int i,int j){ ^ (use --enable-preview to enable unnamed classes) Main.java:49: error: class, interface, enum, or record expected } ^ 13 errors
s929169221
p00042
Java
import java.io.*; class Main{ public static void main(String[] args) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String line=""; int count=1; while(!(line=br.readLine()).equals("0")){ int weight=0; static int W=Integer.parseInt(line); static int n=Integer.parseInt(br.readLine()); static int[] v=new int[n]; static int[] w=new int[n]; static int[][] dp=new int[n+1][W+1]; static boolean[] use=new boolean[n]; for(int i=0;i<n;i++){ String[] str=br.readLine().split(","); v[i]=Integer.parseInt(str[0]); w[i]=Integer.parseInt(str[1]); } System.out.println("Case "+count+":"); System.out.println(MaxValue(0,W)); for(int i=0;i<n;i++){ if(use[i]){ weight+=w[i]; } System.out.println(weight); count++; } } private static int MaxValue(int W,int n,int[] v,int[] w,int[][] dp,int i,int j){ if(dp[i][j]!=0){ return dp[i][j]; } else if(i==n){ return 0; } else if(j>w[i]){ use[i]=false; return dp[i][j]=MaxValue(int W,int n,int[] v,int[] w,int[][] dp,i+1,j); } else{ int p=MaxValue(int W,int n,int[] v,int[] w,int[][] dp,i+1,j); int q=MaxValue(int W,int n,int[] v,int[] w,int[][] dp,i+1,j-w[i])+v[i]; int r=Math.max(p,q); use[i]=(p==r)?false:true; return dp[i][j]=r; } } }
Main.java:10: error: illegal start of expression static int W=Integer.parseInt(line); ^ Main.java:16: error: illegal start of type for(int i=0;i<n;i++){ ^ Main.java:16: error: > or ',' expected for(int i=0;i<n;i++){ ^ Main.java:16: error: <identifier> expected for(int i=0;i<n;i++){ ^ Main.java:21: error: <identifier> expected System.out.println("Case "+count+":"); ^ Main.java:21: error: illegal start of type System.out.println("Case "+count+":"); ^ Main.java:22: error: <identifier> expected System.out.println(MaxValue(0,W)); ^ Main.java:22: error: <identifier> expected System.out.println(MaxValue(0,W)); ^ Main.java:23: error: illegal start of type for(int i=0;i<n;i++){ ^ Main.java:23: error: > or ',' expected for(int i=0;i<n;i++){ ^ Main.java:23: error: <identifier> expected for(int i=0;i<n;i++){ ^ Main.java:40: error: not a statement return dp[i][j]=MaxValue(int W,int n,int[] v,int[] w,int[][] dp,i+1,j); ^ Main.java:40: error: not a statement return dp[i][j]=MaxValue(int W,int n,int[] v,int[] w,int[][] dp,i+1,j); ^ Main.java:43: error: not a statement int p=MaxValue(int W,int n,int[] v,int[] w,int[][] dp,i+1,j); ^ Main.java:43: error: not a statement int p=MaxValue(int W,int n,int[] v,int[] w,int[][] dp,i+1,j); ^ Main.java:44: error: not a statement int q=MaxValue(int W,int n,int[] v,int[] w,int[][] dp,i+1,j-w[i])+v[i]; ^ Main.java:44: error: not a statement int q=MaxValue(int W,int n,int[] v,int[] w,int[][] dp,i+1,j-w[i])+v[i]; ^ Main.java:44: error: not a statement int q=MaxValue(int W,int n,int[] v,int[] w,int[][] dp,i+1,j-w[i])+v[i]; ^ Main.java:31: error: unnamed classes are a preview feature and are disabled by default. private static int MaxValue(int W,int n,int[] v,int[] w,int[][] dp,int i,int j){ ^ (use --enable-preview to enable unnamed classes) Main.java:40: error: ';' expected return dp[i][j]=MaxValue(int W,int n,int[] v,int[] w,int[][] dp,i+1,j); ^ Main.java:40: error: <identifier> expected return dp[i][j]=MaxValue(int W,int n,int[] v,int[] w,int[][] dp,i+1,j); ^ Main.java:40: error: <identifier> expected return dp[i][j]=MaxValue(int W,int n,int[] v,int[] w,int[][] dp,i+1,j); ^ Main.java:40: error: <identifier> expected return dp[i][j]=MaxValue(int W,int n,int[] v,int[] w,int[][] dp,i+1,j); ^ Main.java:40: error: ';' expected return dp[i][j]=MaxValue(int W,int n,int[] v,int[] w,int[][] dp,i+1,j); ^ Main.java:40: error: ';' expected return dp[i][j]=MaxValue(int W,int n,int[] v,int[] w,int[][] dp,i+1,j); ^ Main.java:43: error: ';' expected int p=MaxValue(int W,int n,int[] v,int[] w,int[][] dp,i+1,j); ^ Main.java:43: error: <identifier> expected int p=MaxValue(int W,int n,int[] v,int[] w,int[][] dp,i+1,j); ^ Main.java:43: error: <identifier> expected int p=MaxValue(int W,int n,int[] v,int[] w,int[][] dp,i+1,j); ^ Main.java:43: error: <identifier> expected int p=MaxValue(int W,int n,int[] v,int[] w,int[][] dp,i+1,j); ^ Main.java:43: error: ';' expected int p=MaxValue(int W,int n,int[] v,int[] w,int[][] dp,i+1,j); ^ Main.java:43: error: ';' expected int p=MaxValue(int W,int n,int[] v,int[] w,int[][] dp,i+1,j); ^ Main.java:44: error: ';' expected int q=MaxValue(int W,int n,int[] v,int[] w,int[][] dp,i+1,j-w[i])+v[i]; ^ Main.java:44: error: <identifier> expected int q=MaxValue(int W,int n,int[] v,int[] w,int[][] dp,i+1,j-w[i])+v[i]; ^ Main.java:44: error: <identifier> expected int q=MaxValue(int W,int n,int[] v,int[] w,int[][] dp,i+1,j-w[i])+v[i]; ^ Main.java:44: error: <identifier> expected int q=MaxValue(int W,int n,int[] v,int[] w,int[][] dp,i+1,j-w[i])+v[i]; ^ Main.java:44: error: ';' expected int q=MaxValue(int W,int n,int[] v,int[] w,int[][] dp,i+1,j-w[i])+v[i]; ^ Main.java:44: error: ';' expected int q=MaxValue(int W,int n,int[] v,int[] w,int[][] dp,i+1,j-w[i])+v[i]; ^ Main.java:50: error: class, interface, enum, or record expected } ^ 38 errors
s283718932
p00042
Java
import java.io.*; class Main{ public static void main(String[] args) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String line=""; int count=1; while(!(line=br.readLine()).equals("0")){ int weight=0; int W=Integer.parseInt(line); int n=Integer.parseInt(br.readLine()); int[] v=new int[n]; int[] w=new int[n]; int[][] dp=new int[n+1][W+1]; boolean[] use=new boolean[n]; for(int i=0;i<n;i++){ String[] str=br.readLine().split(","); v[i]=Integer.parseInt(str[0]); w[i]=Integer.parseInt(str[1]); } System.out.println("Case "+count+":"); System.out.println(MaxValue(W,n,v,w,dp,use,0,W)); for(int i=0;i<n;i++){ if(use[i]){ weight+=w[i]; } System.out.println(weight); count++; } } private static int MaxValue(int W,int n,int[] v,int[] w,int[][] dp,boolean[] use,int i,int j){ if(dp[i][j]!=0){ return dp[i][j]; } else if(i==n){ return 0; } else if(j>w[i]){ use[i]=false; return dp[i][j]=MaxValue(W,n,v,w,dp,use,i+1,j); } else{ int p=MaxValue(W,n,v,w,dp,use,i+1,j); int q=MaxValue(W,n,v,w,dp,use,i+1,j-w[i])+v[i]; int r=Math.max(p,q); use[i]=(p==r)?false:true; return dp[i][j]=r; } } }
Main.java:31: error: illegal start of expression private static int MaxValue(int W,int n,int[] v,int[] w,int[][] dp,boolean[] use,int i,int j){ ^ 1 error
s601610536
p00042
Java
import java.util.Scanner; public class AOJ_0042 { Scanner sc = new Scanner(System.in); void run() { for (int T = 1;; T++) { int W = sc.nextInt(); if (W == 0) return; int N = sc.nextInt(); int[] v = new int[N]; int[] w = new int[N]; for (int i = 0; i < N; i++) { String[] in = sc.next().split(","); v[i] = Integer.valueOf(in[0]); w[i] = Integer.valueOf(in[1]); } int maxCost = 0; int minWeight = Integer.MAX_VALUE / 2; int[][] dp = new int[2][W + 1]; for (int i = 0; i < N; i++) { for (int j = 0; j <= W; j++) { if (j - w[i] >= 0) dp[(i + 1) & 1][j] = Math.max(dp[i & 1][j], dp[i & 1][j - w[i]] + v[i]); else dp[(i + 1) & 1][j] = dp[i & 1][j]; if (dp[(i + 1) & 1][j] == maxCost && j < minWeight) { minWeight = j; } else if (dp[(i + 1) & 1][j] > maxCost) { maxCost = dp[(i + 1) & 1][j]; minWeight = j; } } } System.out.println("Case " + T + ":"); System.out.println(maxCost + "\n" + minWeight); } } public static void main(String[] args) { new AOJ_0042().run(); } }
Main.java:3: error: class AOJ_0042 is public, should be declared in a file named AOJ_0042.java public class AOJ_0042 { ^ 1 error
s394930349
p00042
Java
public class Main { Scanner sc = new Scanner(System.in); class t implements Comparable<t> { int worth; int weight; t(String s) { Scanner sc = new Scanner(s.replace(',', ' ')); worth = sc.nextInt(); weight = sc.nextInt(); } public int compareTo(t o) { return this.weight - o.weight; } } void run() { for (int casea = 1;; casea++) { int w = sc.nextInt(); if (w == 0) { break; } w+=1; int n = sc.nextInt(); t[] d = new t[n]; for (int i = 0; i < n; i++) { d[i] = new t(sc.next()); } // Arrays.sort(d); int[] dp = new int[w]; for (int i = 0; i < n; i++) { int[] dp2 = dp.clone(); if (d[i].weight == 0) { for (int j = 0; j < w; j++) { dp[j] = dp2[j] + d[i].worth; } continue; } for (int j = 0; j + d[i].weight < w; j++) { dp[j + d[i].weight] = Math.max(dp2[j + d[i].weight], dp2[j] + d[i].worth); } } int trig = 0; int max = 0; for (int i = 0; i < w; i++) { if (max < dp[i]) { max = dp[i]; trig = i; } else if (max == dp[i]) { if (trig > i) trig = i; } } System.out.println("Case " + casea + ":"); System.out.println(max); System.out.println(trig); } } public static void main(String[] args) { Main m = new Main(); m.run(); } }
Main.java:2: error: cannot find symbol Scanner sc = new Scanner(System.in); ^ symbol: class Scanner location: class Main Main.java:2: error: cannot find symbol Scanner sc = new Scanner(System.in); ^ symbol: class Scanner location: class Main Main.java:9: error: cannot find symbol Scanner sc = new Scanner(s.replace(',', ' ')); ^ symbol: class Scanner location: class Main.t Main.java:9: error: cannot find symbol Scanner sc = new Scanner(s.replace(',', ' ')); ^ symbol: class Scanner location: class Main.t 4 errors
s277284127
p00042
Java
package jp.ac.innami.volume0; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; public class AThief { protected static final int MAX_BAG_WEIGHT = 1000; protected static final int MAX_NUM_TREASURES = 1000; protected static final int MAX_VALUE = 10000; protected static final int WEIGHT = 0; protected static final int VALUE = 1; public static void main(String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int bagWeight = 0; int num_treasures = 0; int caseNumber = 1; ArrayList<Treasure> treasures; Thief thief = new Thief(); while(true){ //かばんの最大積載量を受け取る bagWeight = Integer.parseInt(br.readLine()); if(bagWeight == 0) break; //異常なかばん最大積載量が入力されたら終了する if(bagWeight < 0 || bagWeight > MAX_BAG_WEIGHT) break; Bag bag = new Bag(bagWeight); thief.setBag(bag); //お宝の個数を受け取る num_treasures = Integer.parseInt(br.readLine()); //お宝の数が異常値なら処理を終了する if(num_treasures < 1 || num_treasures > MAX_NUM_TREASURES) break; //お宝情報を入力から取得 treasures = new ArrayList<Treasure>(); for(int i = 0; i < num_treasures; i++){ String[] inputs = (br.readLine()).split(","); int treasureWeight = Integer.parseInt(inputs[WEIGHT]); int treasureValue = Integer.parseInt(inputs[VALUE]); treasures.add(new Treasure(treasureWeight, treasureValue)); } //もっとも軽く、もっとも高価なお宝の組み合わせを選び、かばんにつめる // printList(treasures); thief.sort(treasures); thief.steelTreasures(treasures); // printList(treasures); //かばんの重量とお宝の合計金額を出力する System.out.println("Case " + caseNumber++ + ":"); System.out.println(bag.getCurrentTreasuresWeight()); System.out.println(bag.getCurrentTreasuresValue()); } } private static void printList(ArrayList<Treasure> list){ System.out.println("current list"); for(Treasure t : list){ System.out.println("w:" + t.getWeight() + "v:" + t.getValue() + "v/w:" + t.getValuePerWeight()); } } } class Bag{ private int maxWeight; private int currentWeight; private ArrayList<Treasure> treasures; public Bag(int maxWeight) { this.maxWeight = maxWeight; treasures = new ArrayList<Treasure>(AThief.MAX_NUM_TREASURES); } public void addTreasure(Treasure treasure){ treasures.add(treasure); } public int getMaxWeight() { return maxWeight; } public int getCurrentTreasuresValue(){ int sumOfValue = 0; for(Treasure t : treasures){ sumOfValue += t.getValue(); } return sumOfValue; } public int getCurrentTreasuresWeight(){ int sumOfWeight = 0; for(Treasure t : treasures){ sumOfWeight += t.getWeight(); } return sumOfWeight; } } class Treasure{ private int weight; private int value; private double valuePerWeight; public Treasure(int weight, int value) { this.weight = weight; this.value = value; valuePerWeight = (double)value / (double)weight; } public int getValue() { return value; } public int getWeight() { return weight; } public double getValuePerWeight() { return valuePerWeight; } } class Thief{ private Bag bag; public void setBag(Bag bag) { this.bag = bag; } public void steelTreasures(ArrayList<Treasure> treasuresSorted){ for(int i = treasuresSorted.size() - 1; i >= 0; i--){ //重量当たりの価値が高いお宝から重量の許す限り、袋につめる if(bag.getCurrentTreasuresWeight() + treasuresSorted.get(i).getWeight() <= bag.getMaxWeight()){ bag.addTreasure(treasuresSorted.get(i)); } else{ //DO NOTHING } } } public void sort(ArrayList<Treasure> treasures){ Collections.sort(treasures, new Comparator<Treasure>() { @Override public int compare(Treasure o1, Treasure o2) { double w1 = o1.getValuePerWeight(); double w2 = o2.getValuePerWeight(); int difference = Double.compare(w1, w2); // check result of values comparing // System.out.println(w1 + ((difference > 0)? " gt " : " not gt ") + w2); return difference; } }); } public void introduce(){ System.out.println("My name is Lupin the THIRD."); } }
Main.java:9: error: class AThief is public, should be declared in a file named AThief.java public class AThief { ^ 1 error
s986188406
p00042
Java
package jp.ac.innami.volume0; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; public class Main { protected static final int MAX_BAG_WEIGHT = 1000; protected static final int MAX_NUM_TREASURES = 1000; protected static final int MAX_VALUE = 10000; protected static final int WEIGHT = 0; protected static final int VALUE = 1; public static void main(String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int bagWeight = 0; int num_treasures = 0; int caseNumber = 1; ArrayList<Treasure> treasures; Thief thief = new Thief(); while(true){ //かばんの最大積載量を受け取る bagWeight = Integer.parseInt(br.readLine()); if(bagWeight == 0) break; //異常なかばん最大積載量が入力されたら終了する if(bagWeight < 0 || bagWeight > MAX_BAG_WEIGHT) break; Bag bag = new Bag(bagWeight); thief.setBag(bag); //お宝の個数を受け取る num_treasures = Integer.parseInt(br.readLine()); //お宝の数が異常値なら処理を終了する if(num_treasures < 1 || num_treasures > MAX_NUM_TREASURES) break; //お宝情報を入力から取得 treasures = new ArrayList<Treasure>(); for(int i = 0; i < num_treasures; i++){ String[] inputs = (br.readLine()).split(","); int treasureWeight = Integer.parseInt(inputs[WEIGHT]); int treasureValue = Integer.parseInt(inputs[VALUE]); treasures.add(new Treasure(treasureWeight, treasureValue)); } //もっとも軽く、もっとも高価なお宝の組み合わせを選び、かばんにつめる // printList(treasures); thief.sort(treasures); thief.steelTreasures(treasures); // printList(treasures); //かばんの重量とお宝の合計金額を出力する System.out.println("Case " + caseNumber++ + ":"); System.out.println(bag.getCurrentTreasuresWeight()); System.out.println(bag.getCurrentTreasuresValue()); } } private static void printList(ArrayList<Treasure> list){ System.out.println("current list"); for(Treasure t : list){ System.out.println("w:" + t.getWeight() + "v:" + t.getValue() + "v/w:" + t.getValuePerWeight()); } } } class Bag{ private int maxWeight; private int currentWeight; private ArrayList<Treasure> treasures; public Bag(int maxWeight) { this.maxWeight = maxWeight; treasures = new ArrayList<Treasure>(AThief.MAX_NUM_TREASURES); } public void addTreasure(Treasure treasure){ treasures.add(treasure); } public int getMaxWeight() { return maxWeight; } public int getCurrentTreasuresValue(){ int sumOfValue = 0; for(Treasure t : treasures){ sumOfValue += t.getValue(); } return sumOfValue; } public int getCurrentTreasuresWeight(){ int sumOfWeight = 0; for(Treasure t : treasures){ sumOfWeight += t.getWeight(); } return sumOfWeight; } } class Treasure{ private int weight; private int value; private double valuePerWeight; public Treasure(int weight, int value) { this.weight = weight; this.value = value; valuePerWeight = (double)value / (double)weight; } public int getValue() { return value; } public int getWeight() { return weight; } public double getValuePerWeight() { return valuePerWeight; } } class Thief{ private Bag bag; public void setBag(Bag bag) { this.bag = bag; } public void steelTreasures(ArrayList<Treasure> treasuresSorted){ for(int i = treasuresSorted.size() - 1; i >= 0; i--){ //重量当たりの価値が高いお宝から重量の許す限り、袋につめる if(bag.getCurrentTreasuresWeight() + treasuresSorted.get(i).getWeight() <= bag.getMaxWeight()){ bag.addTreasure(treasuresSorted.get(i)); } else{ //DO NOTHING } } } public void sort(ArrayList<Treasure> treasures){ Collections.sort(treasures, new Comparator<Treasure>() { @Override public int compare(Treasure o1, Treasure o2) { double w1 = o1.getValuePerWeight(); double w2 = o2.getValuePerWeight(); int difference = Double.compare(w1, w2); // check result of values comparing // System.out.println(w1 + ((difference > 0)? " gt " : " not gt ") + w2); return difference; } }); } public void introduce(){ System.out.println("My name is Lupin the THIRD."); } }
Main.java:71: error: cannot find symbol treasures = new ArrayList<Treasure>(AThief.MAX_NUM_TREASURES); ^ symbol: variable AThief location: class Bag 1 error
s391530192
p00042
Java
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; public class Main { protected static final int MAX_BAG_WEIGHT = 1000; protected static final int MAX_NUM_TREASURES = 1000; protected static final int MAX_VALUE = 10000; protected static final int WEIGHT = 0; protected static final int VALUE = 1; public static void main(String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int bagWeight = 0; int num_treasures = 0; int caseNumber = 1; ArrayList<Treasure> treasures; Thief thief = new Thief(); while(true){ //かばんの最大積載量を受け取る bagWeight = Integer.parseInt(br.readLine()); if(bagWeight == 0) break; //異常なかばん最大積載量が入力されたら終了する if(bagWeight < 0 || bagWeight > MAX_BAG_WEIGHT) break; Bag bag = new Bag(bagWeight); thief.setBag(bag); //お宝の個数を受け取る num_treasures = Integer.parseInt(br.readLine()); //お宝の数が異常値なら処理を終了する if(num_treasures < 1 || num_treasures > MAX_NUM_TREASURES) break; //お宝情報を入力から取得 treasures = new ArrayList<Treasure>(); for(int i = 0; i < num_treasures; i++){ String[] inputs = (br.readLine()).split(","); int treasureWeight = Integer.parseInt(inputs[WEIGHT]); int treasureValue = Integer.parseInt(inputs[VALUE]); treasures.add(new Treasure(treasureWeight, treasureValue)); } //もっとも軽く、もっとも高価なお宝の組み合わせを選び、かばんにつめる // printList(treasures); thief.sort(treasures); thief.steelTreasures(treasures); // printList(treasures); //かばんの重量とお宝の合計金額を出力する System.out.println("Case " + caseNumber++ + ":"); System.out.println(bag.getCurrentTreasuresWeight()); System.out.println(bag.getCurrentTreasuresValue()); } } private static void printList(ArrayList<Treasure> list){ System.out.println("current list"); for(Treasure t : list){ System.out.println("w:" + t.getWeight() + "v:" + t.getValue() + "v/w:" + t.getValuePerWeight()); } } } class Bag{ private int maxWeight; private int currentWeight; private ArrayList<Treasure> treasures; public Bag(int maxWeight) { this.maxWeight = maxWeight; treasures = new ArrayList<Treasure>(AThief.MAX_NUM_TREASURES); } public void addTreasure(Treasure treasure){ treasures.add(treasure); } public int getMaxWeight() { return maxWeight; } public int getCurrentTreasuresValue(){ int sumOfValue = 0; for(Treasure t : treasures){ sumOfValue += t.getValue(); } return sumOfValue; } public int getCurrentTreasuresWeight(){ int sumOfWeight = 0; for(Treasure t : treasures){ sumOfWeight += t.getWeight(); } return sumOfWeight; } } class Treasure{ private int weight; private int value; private double valuePerWeight; public Treasure(int weight, int value) { this.weight = weight; this.value = value; valuePerWeight = (double)value / (double)weight; } public int getValue() { return value; } public int getWeight() { return weight; } public double getValuePerWeight() { return valuePerWeight; } } class Thief{ private Bag bag; public void setBag(Bag bag) { this.bag = bag; } public void steelTreasures(ArrayList<Treasure> treasuresSorted){ for(int i = treasuresSorted.size() - 1; i >= 0; i--){ //重量当たりの価値が高いお宝から重量の許す限り、袋につめる if(bag.getCurrentTreasuresWeight() + treasuresSorted.get(i).getWeight() <= bag.getMaxWeight()){ bag.addTreasure(treasuresSorted.get(i)); } else{ //DO NOTHING } } } public void sort(ArrayList<Treasure> treasures){ Collections.sort(treasures, new Comparator<Treasure>() { @Override public int compare(Treasure o1, Treasure o2) { double w1 = o1.getValuePerWeight(); double w2 = o2.getValuePerWeight(); int difference = Double.compare(w1, w2); // check result of values comparing // System.out.println(w1 + ((difference > 0)? " gt " : " not gt ") + w2); return difference; } }); } public void introduce(){ System.out.println("My name is Lupin the THIRD."); } }
Main.java:69: error: cannot find symbol treasures = new ArrayList<Treasure>(AThief.MAX_NUM_TREASURES); ^ symbol: variable AThief location: class Bag 1 error
s856667714
p00042
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; public class Main { protected static final int MAX_BAG_WEIGHT = 1000; protected static final int MAX_NUM_TREASURES = 1000; protected static final int MAX_VALUE = 10000; protected static final int WEIGHT = 0; protected static final int VALUE = 1; public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int bagWeight = 0; int num_treasures = 0; int caseNumber = 1; ArrayList<Treasure> treasureList; while(true){ //bagを生成 bagWeight = Integer.parseInt(br.readLine()); if(bagWeight <= 0 || bagWeight > MAX_BAG_WEIGHT) break; //お宝リストを生成 treasureList = new ArrayList<Treasure>(); num_treasures = Integer.parseInt(br.readLine()); if(num_treasures < 1 || num_treasures > MAX_NUM_TREASURES) break; for(int i = 0; i < num_treasures; i++){ String[] inputs = (br.readLine()).split(","); int treasureValue = Integer.parseInt(inputs[WEIGHT]); int treasureWeight = Integer.parseInt(inputs[VALUE]); treasureList.add(new Treasure(treasureWeight, treasureValue)); } //動的計画法 int[] maxValueOfEachWeight = getMaxValue(bagWeight, treasureList); //価値がもっとも高いときの、もっとも軽い重量を出力する System.out.println("Case " + caseNumber++ + ":"); System.out.println(maxValueOfEachWeight[maxValueOfEachWeight.length - 1]); System.out.println(getMinWeightWhenMaxValue(maxValueOfEachWeight)); } } public static int[] getMaxValue(int bagWeight, ArrayList<Treasure> treasureList){ int[] maxValue = new int[bagWeight + 1]; //各バッグ積載可能重量での最大valueを格納する //重量が0のとき、treasureはつめないためvalue = 0 maxValue[0] = 0; //バッグには何もつめられていないため、0で初期化 Arrays.fill(maxValue, 0); //各treasureについて、バッグ積載可能重量に空きがあり、 //treasureを追加することでvalueが大きくなるなら追加していく for(int i = 0; i < treasureList.size(); i++){ int treasureWeight = treasureList.get(i).getWeight(); int treasureValue = treasureList.get(i).getValue(); for(int j = bagWeight; j >= treasureWeight; j--){ if(maxValue[j - treasureWeight] < 0){ //treasureが詰められない場合は次のアイテムを検討する break; } int tmpValue = maxValue[j - treasureWeight] + treasureValue; maxValue[j] = Math.max(maxValue[j], tmpValue); } } return maxValue; } public static int getMinWeightWhenMaxValue(int[] maxValueOfEachWeight){ int minWeight = maxValueOfEachWeight.length - 1; int maxValue = maxValueOfEachWeight[minWeight]; for(int weight = maxValueOfEachWeight.length - 2; weight >= 0; weight--){ if(maxValue > maxValueOfEachWeight[weight]){ break; } minWeight = weight; } return minWeight; } }
Main.java:47: error: cannot find symbol public static int[] getMaxValue(int bagWeight, ArrayList<Treasure> treasureList){ ^ symbol: class Treasure location: class Main Main.java:20: error: cannot find symbol ArrayList<Treasure> treasureList; ^ symbol: class Treasure location: class Main Main.java:27: error: cannot find symbol treasureList = new ArrayList<Treasure>(); ^ symbol: class Treasure location: class Main Main.java:34: error: cannot find symbol treasureList.add(new Treasure(treasureWeight, treasureValue)); ^ symbol: class Treasure location: class Main 4 errors
s048952328
p00042
Java
import java.util.Arrays; import java.util.Scanner; import java.util.Stack; public class Main2 { static int W,N; static int[][] dp; static int[][] a; static int max,minw; static Stack<Integer>stack; public static void main(String[] args) { Scanner cin=new Scanner(System.in); int T=0; for(;;){ T++; W=cin.nextInt(); if(W==0)break; max=-(1<<30); minw=1<<30; stack=new Stack<Integer>(); N=cin.nextInt(); dp=new int[N+1][W+1]; a=new int[N][2]; for(int i=0;i<N;i++){ Arrays.fill(dp[i], 1<<30); String[] s=cin.next().split(","); a[i][0]=Integer.parseInt(s[0]); a[i][1]=Integer.parseInt(s[1]); } dp(0,W); System.out.println("Case "+T+":"); System.out.println(max+"\n"+(minw-1)); } } static int dp(int t,int w){ int re=0; if(t==N){ return 0; } if(dp[t][w]!=1<<30)return dp[t][w]; if(w-a[t][1]<0){ re=dp(t+1,w); } else{ re=Math.max(dp(t+1,w), dp(t+1,w-a[t][1])+a[t][0]); if(re>max){ max=re; minw=w; } else if(re==max){ minw=Math.min(minw, w); } } return dp[t][w]=re; } }
Main.java:5: error: class Main2 is public, should be declared in a file named Main2.java public class Main2 { ^ 1 error
s733880101
p00042
Java
import java.util.*; public class AOJ_0042{ void run(){ Scanner sc = new Scanner(System.in); int case_cnt = 1; while(true){ int W = sc.nextInt(); if(W == 0){ break; } int N = sc.nextInt(); int[] value = new int[N]; int[] weight = new int[N]; for(int i = 0; i < N; i++){ String[] s = sc.next().split(","); value[i] = Integer.parseInt(s[0]); weight[i] = Integer.parseInt(s[1]); } int[] dp = new int[W+1]; for(int i = 0; i < N; i++){ for(int w = W; w >= 0 ; w--){ if( w + weight[i] <= W){ dp[w + weight[i]] = Math.max(dp[w + weight[i]], dp[w] + value[i]); } } } int max = 0; for(int w: dp){ max = Math.max(max,w); } int index = 0; for(int i = 0; i <= W; i++){ if(dp[i] == max){ index = i; break; } } System.out.println("Case " + case_cnt + ":"); System.out.println(max); System.out.println(index); case_cnt++; } } public static void main(String[] args){ new AOJ_0042().run(); } }
Main.java:3: error: class AOJ_0042 is public, should be declared in a file named AOJ_0042.java public class AOJ_0042{ ^ 1 error
s221872624
p00042
C
#include<stdio.h> #include<stdlib.h> int main(void) { int count = 0; int W; int N; while(scanf("%d",&W)){ if(W==0) break; count++; scanf("%d",&N); char c; int va;//お宝の価値 int wi;//お宝の重さ int li[W+1];//袋の限界 int i,j; for(i=0;i<=W;i++) li[i]=0;//お宝が入っていない for(i=0;i<N;i++){ scanf("%d%c%d",&va,&c,&wi); for(j=W;j>=0;j--){ if(li[j]!=0 && wi+j<=W){ if(li[j]+va > li[wi+j]) li[wi+j]=li[j]+va; } if(j==0 && wi <= W){ if(va > li[wi]) li[wi]=va; } } } int ansva=0; int answi=0; for(i=0;i<=W;i++){ if(li[i]>ansva){ ansva = li[i]; answi = i; } } printf("Case %d:\n",count); printf("%d\n%d\n",ansva,answi); }
main.c: In function 'main': main.c:44:3: error: expected declaration or statement at end of input 44 | } | ^
s018240152
p00042
C
#include<stdio.h> int w, n, value[1000], weight[1000]; int search(int i, int w, int value_s) { if (i == n) { return value_s; } else if (w < weight[i]) { return search(i + 1, w, value_s); } else { int result1 = search(i + 1, w, value_s); int result2 = search(i + 1, w - weight[i], value_s + value[i]); return max(result1, result2); } } int main(void) { int i,j=0; int value_s; while (1) { scanf("%d", &w); if (w == 0)break; scanf("%d", &n); j++; for (i = 0; i < n; i++) scanf("%d,%d", &value[i], &weight[i]); value_s = search(0, w,0); printf("Case %d:\n",j); printf("%d\n", value_s); } return 0; }
main.c: In function 'search': main.c:14:24: error: implicit declaration of function 'max' [-Wimplicit-function-declaration] 14 | return max(result1, result2); | ^~~
s641400280
p00042
C
#include<stdio.h> #define max(a,b)(((a)>(b))>(a):(b)) int w, n, value[1001], weight[1001]; int weight_s,dp[1001][1001]; void search() { for (int i = 0; i < n; i++) { for (int j = 0; j <= w; j++) { if (j < weight[i]) { dp[i + 1][j] = dp[i][j]; }else{ dp[i + 1][j] = max(dp[i][j],dp[i][j-weight[i]]+value[i]); } } } for (int j = 0; j <= w; j++) { if (dp[n][j] == dp[n][w]) { weight_s = j; break; } } } int main(void) { int i,j,k=0; while (1) { scanf("%d", &w); if (w == 0)break; scanf("%d", &n); k++; for (i = 0; i < 1001; i++) { for (j = 0; j < 1001; j++) { dp[i][j] = 0; } } for (i = 0; i < n; i++) scanf("%d,%d", &value[i], &weight[i]); search(); printf("Case %d:\n",k); printf("%d\n", dp[n][w]); printf("%d\n",weight_s); } return 0; }
main.c: In function 'search': main.c:2:31: error: expected ')' before ':' token 2 | #define max(a,b)(((a)>(b))>(a):(b)) | ~ ^ main.c:12:48: note: in expansion of macro 'max' 12 | dp[i + 1][j] = max(dp[i][j],dp[i][j-weight[i]]+value[i]); | ^~~