|
|
Common Board#include<iostream> using namespace std; int main() { int x, y; int sum1 = 0, sum2 = 0; char n = 'n'; cin >> x; int max = x + 1; int min = x - 1; for (int i = 0; i <3; i++) { y = max % 10; max = max / 10; sum1 += y; } for (int i = 0; i < 3; i++) { y = max % 10; max = max / 10; sum2 += y; } if (sum2 == sum1) { n = 'y'; }
y = 0; sum1 = 0; sum2 = 0; for (int i = 0; i <3; i++) { y = min % 10; min = min / 10; sum1 += y; } for (int i = 0; i <3; i++) { y = min % 10; min = min / 10; sum2 += y; } if (sum2 == sum1) { n = 'y'; } if (n=='n') { cout << "no"; } else { cout << "yes"; } return 0; } choose k numbers k1,k2...km such that sigma(cos((2*ki+1)*pi/n))==0&&sigma(sin((2*ki+1)*pi/n))==0 that is sigma(cos((2*ki+1)*pi/n)+sin((2*ki+1)*pi/n)*i)==0 because cos(k*theta)+i*sin(k*theta)==(cos(theta)+i*sin(theta)^k so it is sigma(cos(pi/n)+i*sin(pi/n))^(2*ki+1)==0 I think this problem must involved this... is there O(polynomial)algo ? I only came up with a brute_force search idea..maybe it can pass.. brute_force search compnent part which is central symmetry Edited by author 22.11.2017 08:15 seems can turn to minimum cut problem because there are only two prime factor,I didn't see it... What is test # 14? Can anyone help me? Edited by author 22.11.2017 20:14 #include<stdio.h> #include<math.h> #define n 4 int main(){ int a[n]={100000000}; int i; for(i=0; i<n; i++) scanf("%d", &a[i]); for(i=n; i>0; i--){ printf("%.4f\n", sqrt(a[i]));} return 0; } #include<stdio.h> #include<math.h> #define n 4 int main(){ int a[n]={100000000}; int i; for(i=0; i<n; i++) scanf("%d", &a[i]); for(i=0; i<n; i++){ printf("%.4f\n", sqrt(a[i]));} return 0; } Can someone know the 9th test? the topic is closed, a simple bug Wrong answer 4. HELP!!!! Edited by author 03.06.2016 17:42 Edited by author 03.06.2016 17:42 What did you try? What's your solution/idea so far? #include "iostream" using namespace std; int main() { int n, k, hours = 0, game = 1, free, i = 0, j = 0; cin >> n >> k; free = k; if (n == 1) hours = 0; else { while ((free > i) && (game < free) && (game <= n)) { i++; n -= i; hours++; game += i; } while (j < n-1) { hours++; j += k; } } cout << hours << endl; return 0; } Edited by author 03.06.2016 17:44 Wrong answer 4! Edited by author 03.06.2016 17:30 Edited by author 03.06.2016 17:41 same code visul C++ 2017 0.249s G++7.1 2.5s Hi, everyone! I used Manacher's algorithm to solve this problem, but I got WA on #14 test. Can someone hint me, what could be the problem? It could be buggy implementation If just want to solve then you could do it with native algorithm, time limit is enough even for python Mahilewets Nikita, thanks you for your answer! I thought about the native solution already, but I want to solve it with Manacher's algorithm only. It is needed for increasing of my skills :) If someone has 14th test post it, please! OMG, I found my mistake :) This test was useful to me: 'babadada'. Right answer is 'adada' (not 'abada'). P.s. There is same problem at Codeleet. You may peek some test there :) Also my implementation of Manacher failed at test 5 And I decided to use naive please give the code to java please give the code to java Edited by author 18.11.2017 07:25 #include<iostream> #include<cstdio> using namespace std; int main() { int n, a = 1, counter = 0; string s; cin >> n; for (int i = 0; i < n; ++i) { cin >> s; if (s[0] == 'A' || s[0] == 'P' ||s[0] == 'O' ||s[0] == 'R' && a == 2){ a = 1; counter++;} else if (s[0] == 'A' || s[0] == 'P' ||s[0] == 'O' ||s[0] == 'R' && a == 3){ a = 1; counter +=2;} if (s[0] == 'B' || s[0] == 'M' ||s[0] == 'S' && a == 1){ a = 2; counter++;} else if (s[0] == 'B' || s[0] == 'M' ||s[0] == 'S' && a == 3){ a = 2; counter++;} if (s[0] == 'D' || s[0] == 'G' ||s[0] == 'K' ||s[0] == 'T' || s[0] == 'W' && a == 1){ a = 3; counter +=2;} else if (s[0] == 'D' || s[0] == 'G' ||s[0] == 'K' ||s[0] == 'T' || s[0] == 'W' && a == 2){ a = 3; counter++;} } cout << counter; return 0; } You list D, G, K, T, W, but not J. initially let result sequence to be 10* 10* 10* 0* means zero or more zeroes. every time choose two number and if we merge them produce a smaller number then we merge them. the procedure stops until we can't merge to get a smaller number is it correct?? seems to be.. Edited by author 16.11.2017 07:10 we should modify this algo: every time choose right most two number that we merge them can get a smaller number then we merge them,.... we must merge numbers from right to left.... seems to be more correct Anyone crash test#2 Test #2 contains graph with only one node aaaaa aaa No aaa aaaaa aaaaaaaaa No aaaa aaaaa aabaa aabaabaabaaaaabaa No aab aab aaba aa aabaa aabaa aabaabaab No aab aab aab abcabcabccs abcaabcaabcaa No abca abca abca a aabaa aabaabaaaa No aab aabaa aa What's wrong? I have 'time limit excedeed' in 9th test. import functools def pr(n): result = [] i = 2 now = 1 while n >= 1: if n % i == 0: now *= i n //= i elif n % i != 0 and now > 1: result.append(now) i += 1 now = 1 else: i += 1 if n == 1: result.append(now) return result def f(n): result = 0 i = 1 while i ** 2 < n: if n % i == 0: result += 1 i += 1 if i ** 2 == n: return 2 * result + 1 else: return 2 * result newList = [int(input()) for _ in range(10)] product = functools.reduce((lambda x, y: x * y), newList) print(functools.reduce(lambda x, y: x * y, map(f, pr(product))) % 10) You don't must develop hard solution. Your work should not payed many time. Just pay attention, and look again on tests. Attention will save your time. I am sorry, for my poor English. Good luck! Edited by author 18.10.2015 16:52 Нужен максимум из 4-х минимумов) Edited by author 11.11.2017 22:53 Edited by author 11.11.2017 22:53 |
|
|