Common BoardI got WA 10, where is wrong? /////////////////////// #include <iostream> using namespace std; int main() { int N,M,sum,counter,mul; counter=0; cin>>N>>M; sum=M; mul=N*M; while(sum!=mul) { N--; sum+=N; counter++; if(sum==mul) break; M--; sum+=M; counter++; } cout<<counter<<endl; } Try different epsilons. I got AC with solution that had WA 30,32,34 before that. And all that i changed was epsilon. Better solution would be to do all calculation in integer types (e.g. long long) - thus you avoid precision issues. #include <iostream> #include <math.h> #include <iomanip> using namespace std; int main() { float a[4] = { 0 }; int i;
for (i = 0; i < 4; i++){ cin >> a[i]; }
for (i = 0; i < 4; i++){ printf("%.4f\n", sqrt(a[i])); } return 0; } А кто вам сказал, что чисел будет ровно 4? Hi all. I tried to solve this problem with standart method. I devide all numbers on GCD, and calculate all x in A*x + B*y and I tried find the maximum T, T <= N. In cicle I write something like this: if ( max < T ) { max = T; //something too } and have WA16. After WA16 I tried fix my program, but don't find anything global. Fix something right on wrong, I 13 times get WA 1 - 16. Then I changed ( max < T ) on ( max <= T ), and don't send, because did not think, what that will be changed WA16 on AC. I was wrong. I don't know why that fix is right, can someone explain me? Thanks. Sorry for bad English. Test 2 2 1 Ouch... Thanks, I understood my problem. I am write int q, w; instead of int q = 0, w = 0; #include <iostream> #include <string> using namespace std; int main() { int n; cin>>n; int p[n]; string posi; for(int i=0; i<n; i++) { cin>>posi; if ((posi[0]<'a'||posi[0]>'h')||(posi[1]<'1'||posi[1]>'8')) return 0; if (posi[0]>='c'&&posi[0]<='f') { if (posi[1]>='3'&&posi[1]<='6') p[i]=8; if (posi[1]=='2'||posi[1]=='7') p[i]=6; if (posi[1]=='1'||posi[1]=='0') p[i]=4; } if (posi[0]=='b'||posi[0]=='g') { if (posi[1]>='3'&&posi[1]<='6') p[i]=6; if (posi[1]=='2'||posi[1]=='7') p[i]=4; if (posi[1]=='1'||posi[1]=='8') p[i]=3; } if (posi[0]=='a'||posi[0]=='h') { if (posi[1]>='3'&&posi[1]<='6') p[i]=4; if (posi[1]=='2'||posi[1]=='7') p[i]=3; if (posi[1]=='1'||posi[1]=='8') p[i]=2; } } for (int i=0; i<n; i++) cout<<p[i]<<endl; return 0; } hi,in your code you should consider 'a','h',1,8. for example :if ((posi[0]<='a'||posi[0]>='h')||(posi[1]<='1'||posi[1]>='8')) Can not get past this one, all tests in the discussion are passed correctly. Can anyone hint on why test #3 may be failed? Maybe you are adding a 'space' after the last word too. Space should not be counted after the last word. Help me. I got WA7. Give me some test. I was failing this test because I printed stuff after IMPOSSIBLE (restoring solution even though I found there shouldn't be one). try this test: 11 answer is 11, not 1 And try tests: 122 221 121 :D wa on test24 who can help me!= = what's the data? Only my personal opinions, hope they can help you.☺ If you stuck on WA#3, try the following understanding: The description said "A component of a salad could be a basic ingredient or [another] salad", but Test 3 may contain some cases in which the component of a salad is this salad itself. If you stuck on WA#6, please remember that "Percentages should be output with an absolute or relative error no more than 10−3" Is there somebody who can give me input data for test #2? Try this test: 5 5 2 2 2 3 4 answer: 0 0 Try this test: 10 e e f f unknown g unknown g d d Answer: Igor is wrong. But my programm gave me "5", because i forgot check v[j] when last="unknown". if (last == "unknown" && v[j] != "unknown") { last = v[j]; if (m[last] == true) f = false; } Very simple problem, only what you need is to read the directions of buttons more CAREFULLY. Their keyboard is like 0 789 456 123 Edited by author 11.07.2014 06:36 1=(y-1*sqrt(2)/2) (x-1*sqrt(2)/2) 7=(y+1*sqrt(2)/2) (x-1*sqrt(2)/2) 9=(y+1*sqrt(2)/2) (x+1*sqrt(2)/2) 3=(y-1*sqrt(2)/2) (x+1*sqrt(2)/2) 2=(y-1) 8=(y+1) 4=(x-1) 6=(x+1) that's all Edited by author 09.02.2006 18:40 Edited by author 11.07.2014 06:30 Thanks, It was realy easy, but I read the directions of buttons not exactly and that's why got WA :-) The answer of simple test not one, right this answer too: 6 6 1 2 3 3 4 5 5 2 5 3 4 3 1 It's hepled me. Sorry, for bad English. Some tests: 6 6 1 2 3 4 5 6 6 1 6 2 5 3 4 6 3 1 2 3 2 1 1 5 1 3 2 2 1 1 10 10 6 3 4 5 2 10 10 5 4 1 8 1 10 2 10 5 6 5 4 4 3 1 6 6 1 6 2 3 3 3 2 3 3 3 3 2 2 1 2 2 2 1 3 3 2 3 2 3 2 3 2 3 3 2 2 3 3 2 3 2 3 3 1 1 3 3 1 3 1 6 6 5 5 5 1 1 1 4 5 5 5 1 1 1 6 7 6 6 6 2 2 2 6 2 6 2 6 2 6 6 8 6 6 6 2 2 2 4 6 6 6 2 2 2 Edited by author 10.07.2014 03:47 abcba bc => aba abcbc bc => abbbc cba ba => abcba a bbcc => a a bbccc => abbc d bbcc => bbccd Why OLE 24? #pragma comment(linker, "/STACK:64777216") #define _CRT_SECURE_NO_WARNINGS #include<iostream> #include<stdio.h> #include<algorithm> #include<vector> #include<math.h> #include<string> #include<sstream> #include<set> #include<map> #include<stack> #include<queue> #include<deque> #include<memory.h> #include<ctime> #include<cassert> #define pb push_back #define sz(a) (int)a.size() #define bs binary_search #define np next_permutation #define mp make_pair #define all(a) a.begin(),a.end() #define read(a) scanf("%d", &a) #define writeln(a) printf("%d\n", a); #define forn(i, n) for (int i = 0; i < n; ++i) #define forv(i, v) for (int i = 0; i < sz(v); ++i) #define _(a, b) memset(a, b, sizeof a) typedef long long ll; typedef unsigned long long ull; using namespace std; template<class T> inline T sqr(T x) { return x * x; } const double pi = acos(-1.0), eps = 1e-18; const int INF = 1000 * 1000 * 1000, MAXN = 100005, MOD = INF + 7; string s, t, ls, ans = ""; int kmp[75000 * 2 + 5]; vector<int> pos; char al[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'}; void prepare(string s) { #ifdef _DEBUG freopen("input.txt", "r", stdin); freopen("output.txt","w",stdout); #else if (sz(s) != 0) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } #endif } void gen () { srand(time(NULL)); string TMP = ""; forn (i, 70000) { int k = rand() % 8; cout << al[k]; TMP += al[k]; } cout << '\n'; cout << TMP; } void solve() { cin >> s >> t; ls = s + "*" + t; kmp[0] = 0; for (int i = 1; i < sz(ls); i++) { int k = kmp[i-1]; while (k > 0 && ls[i] != ls[k]) { k = kmp[k-1]; } if (ls[i] == ls[k]) ++k; kmp[i] = k; } for (int i = sz(s) + 1; i < sz(ls); i++) { if (kmp[i] == 0) { cout << "Yes"; return; } if (i != sz(s) + 1 && kmp[i] <= kmp[i-1]) pos.pb(kmp[i - kmp[i]]); } pos.pb(kmp[sz(ls)-1]); cout << "No\n"; string tmp = ""; int cnt = 0; forn (i, sz(pos)) { bool f = false; cnt += pos[i]; forn (j, pos[i]) { cout << s[j]; f = true; } if (i != sz(pos) - 1 && pos[i]) cout << " "; } } int main() { prepare(""); //gen(); solve(); return 0; } Edited by author 09.07.2014 23:18 #include <iostream> #include <vector> #include <string> #include <cstring> #include <string.h> #include <fstream> using namespace std; struct our { char a[10]; }; char temp[10]; our V[105]; int SizeV; int main() { freopen("output.txt","w",stdout); freopen("input.txt","r",stdin); bool doit = true; int SizeV = -1; while(doit) if(strlen(temp) == 1 && temp[0] == '#') doit = false; else { ++SizeV; for(int k = 0; k < strlen(temp); k++) V[SizeV].a[k] = temp[k]; cin >> temp; } char a; char word[105]; int fails = 0; string s; getline(cin,s); char r; while(getline(cin,s)) { if(s.size() != 0) { int i = 0; char word[10]; while(i < s.size()) { int wordind = -1; while(s[i] >= 'a' && s[i] <= 'z') { word[++wordind] = s[i]; i++; } bool done = false; int nuz = 0; for(int j = 0; j <= SizeV; j++) { int error = 0; if((wordind+1) == strlen(V[j].a)) { for(int k = 0; k <= wordind; k++) if(word[k] != V[j].a[k]) { error++; if(error > 1) break; } if(error == 1) { done = true; nuz = j; fails++; break; } } } if(done) for(int e = 0; e < strlen(V[nuz].a); e++) cout << V[nuz].a[e]; else for(int e = 0; e <= wordind; e++) cout << word[e]; cout << s[i++]; } } cout << endl; } cout << fails << endl; fclose(stdin); fclose(stdin); return 0; } Edited by author 09.07.2014 20:44 |
|