| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
| Hint | Md sabbir Rahman | 1578. Охота на мамонта | 14 ноя 2018 20:31 | 1 |
Hint Md sabbir Rahman 14 ноя 2018 20:31 If you're stuck think like this, having a directed segment AB, you just need a C among the remaining points s.t. <CBA is acute. Fixing A, is there a way to choose B such that any C among remaining will form acute <CBA ? |
| I have WA#2 | ura | 1468. Дробь | 14 ноя 2018 06:14 | 1 |
That is test 2 Edited by author 14.11.2018 06:18 |
| ASD | buyolitsez | 1118. Нетривиальные числа | 13 ноя 2018 22:11 | 1 |
ASD buyolitsez 13 ноя 2018 22:11 assc Edited by author 20.03.2019 19:54 |
| who can tell me test 3 plesaseeeeee write answer | BOTLMahir | 1118. Нетривиальные числа | 13 ноя 2018 22:11 | 4 |
My code gives true answers for all tests but when I send problem it gives WA in test 3. please write answer. test 3 is nothing, but 2 1000000. So how should the answer look like? Is it the biggest possible prime number? you are right, just prime number |
| help me, find mistake, 5 test | buyolitsez | 1991. Битва у болота | 13 ноя 2018 21:04 | 1 |
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { ios_base::sync_with_stdio(false); cout.tie(0); cin.tie(0); int n,k; cin >> n >> k; int dontused=0,dontdie=0; int f; for(int i=0;i<n;i++) { cin >> f; if(k>f) { dontdie+=k-f; } if(k<f) { dontused+=f-k; } } cout << dontused << " " << dontdie; return 0; } |
| Getting TLE | Ahmad Jamaly Rabib | 1086. Криптография | 13 ноя 2018 01:46 | 2 |
What is the problem with my code? #include <iostream> using namespace std; #include <cmath> bool check_prime(double n) { int c; for (c=2;c<= sqrt(n);c++) { if((int) n%c==0) return 0; } if(c==(int) n) return 1; } int nth_prime(int n){ int m=1; while (n>0) { m++; if (m == 2) { n--; } if (m%2!=0) { if (check_prime(m)==1) { n--; } } } return m;
} int main() { int n,m,i,a[15000],s; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d",&a[i]); } for(i=0;i<n;i++){ s = nth_prime(a[i]); printf("%d\n",s); } return 0; } |
| Why it is wrong? | иван | 1567. SMS-спам | 12 ноя 2018 21:22 | 1 |
a=input() c=0 c+=a.count('a') c+=a.count('d') c+=a.count('g') c+=a.count('j') c+=a.count('m') c+=a.count('p') c+=a.count('s') c+=a.count('v') c+=a.count('y') c+=a.count('y') c+=a.count('.') c+=a.count(' ') c+=a.count('b')*2 c+=a.count('e')*2 c+=a.count('h')*2 c+=a.count('k')*2 c+=a.count('n')*2 c+=a.count('q')*2 c+=a.count('t')*2 c+=a.count('w')*2 c+=a.count('z')*2 c+=a.count(',')*2 c+=a.count('c')*3 c+=a.count('f')*3 c+=a.count('i')*3 c+=a.count('l')*3 c+=a.count('o')*3 c+=a.count('r')*3 c+=a.count('u')*3 c+=a.count('x')*3 c+=a.count('!')*3 print(c) |
| WA 20 With Dijkstra. What to do? | Kogut.Ivan'` | 1871. Сейсмические волны | 12 ноя 2018 18:27 | 1 |
I can't understand problem in my algorithm. Can it be solved with just Dijkstra? |
| How to slove it?? Any hints? | tbtbtb91 | 1260. Фотограф-зануда | 12 ноя 2018 11:39 | 25 |
let A[i][j] be the number of i permutations that start with j and we jump 2. The recurrence is: a[i][1] = a[i - 1][1] + a[i - 1][2], a[i][2] = a[i - 1][2] + a[i - 3][2] I use the same methon...But I got Wa???? We can do it more easyly! Just think of this: 1 2 ... means N - 1; 1 3 2 4 means N - 3; 1 3 5 7...6 4 2 only 1; 1 3 4 2 (only N == 4); So we can DP; You can using this: Initilization: a[1]:=1; a[2]:=1; a[3]:=2; And solve: a[i]:=a[i-1]+a[i-3]+1; So, your answer in a[n] I konw why I was WA...... Very thanks!!!! Well, actually I decovered this formula after writing brute force algorithm. I am wondering how it could be proven. Any ideas? Edited by author 10.04.2004 02:04 But Timgreen had almost proved it. write the permutations down and look it carefully as hard as you can and you'll find out sth useful for you associated with the informations provided above by all the upper friends... Can somebody give tests? for exmaple for 6,10,55... Thanks. for 6 , ans = 9 for 10, ans = 46 for 55, ans = 1388937263 I don't understand your formula . Could you explain ? Take i=5 for example The permutations are: 1 2 3 4 5 1 2 3 5 4 1 2 4 3 5 1 2 4 5 3 1 3 2 4 5 1 3 5 4 2 a[i-1] stands for the first four, beginning with '1 2'. If you ignore 1, you have the same prob for N=i-1. a[i-3] stands for the fifth, beginning with '1 3 2 4'. If you ignore 1, 3, 2, you have the same prob for N=i-3. And a special case (the last) -- all the odds in increasing order, followed by all the evens in decreasing order. The is what the +1 in the formula means. Good luck! I used another method to solve this. Suppose we have N numbers. We will care about five possible configurations: K(n) ... n n-1 ... T(n) ... n-1 n ... E(n) ... n-2 n P(n) ... n n-1 S(n) ... n-1 n here K(n) is the number of correct configurations of the first type and so on. It's clear that the answer for N will be K(N)+T(N)+E(N)+P(N)+S(N). So, what we need to do is understand how to get K(n+1),T(n+1)... from K(n),T(n),... And it is very easy to see that following is true: K(n+1) = T(n) T(n+1) = K(n)+P(n) E(n+1) = P(n) P(n+1) = S(n) S(n+1) = S(n)+E(n) I don't know if we can call this a proof. This is an observation I guess. Take i=5 for example The permutations are: 1 2 3 4 5 1 2 3 5 4 1 2 4 3 5 1 2 4 5 3 1 3 2 4 5 1 3 5 4 2 a[i-1] stands for the first four, beginning with '1 2'. If you ignore 1, you have the same prob for N=i-1. a[i-3] stands for the fifth, beginning with '1 3 2 4'. If you ignore 1, 3, 2, you have the same prob for N=i-3. And a special case (the last) -- all the odds in increasing order, followed by all the evens in decreasing order. The is what the +1 in the formula means. Good luck! My idea is : (a bit complicated) definition : dp[x][0][0] = [...] , x , x-1 , [...] dp[x][0][0] = [...] , x-1 , x-1 , [...] dp[x][1][0] = [...] , x , x-1 dp[x][1][0] = [...] , x-1 , x dp[x][1][0] = [...] , x-2 , x (dp[x][i][j] is number of sequences satisfying the corresponding rule) recurrence : dp[i][0][0] = dp[i-1][0][1]; dp[i][0][1] = dp[i-1][0][0] + dp[i-1][1][0]; dp[i][1][0] = dp[i-1][1][1]; dp[i][1][1] = dp[i-1][1][1] + dp[i-1][1][2]; dp[i][1][2] = dp[i-1][1][0]; answer (to be printed is) : dp[n][0][0] + dp[n][0][1] + dp[n][1][0] + dp[n][1][1] + dp[n][1][2] proof : left for you :) Edited by author 02.05.2013 19:18 I have observed the answers.I found that a[i]=a[i-1]+a[i-2]-a[i-5]; I still don't know why! Above has been shown: a[i] = a[i-1] + a[i-3] + 1 this holds for each i, then also: a[i-2] = a[i-3] + a[i-5] + 1 So a[i-2] - a[i-3] - a[i-5] = 1 and (substitute this result in the first equation) a[i] = a[i-1] + a[i-3] + a[i-2] - a[i-3] - a[i-5] which reduces to a[i] = a[i-1] + a[i-2] - a[i-5] Can you explain your formul?how should I use it!) cool, note that we can unite 3rd and 4th cases as one case when n >= 4. my formula is: a[i][1] = a[i-1][1] + a[i-2][2] a[i][2] = a[i-2][1] + 1 But i don't understand your formula? Could you explain?? Edited by author 14.07.2008 22:25 I've solved it with help of asympthotic. Starting from 20 - 25-th member (it can be found recursively) - a[i] ~ a[i-1]*(a[i-1]/a[i-2]) I use dfs to find the regular for some test n = 1 2 3 4 5 6 7 8 9 10 11 ans= 1 2 2 4 6 9 14 21 31 46 68 then I found f[n] = f[n-1] + f[n-2] - f[n-5] then I got AC. |
| why wrong answer on test case #2 ? | Al - Amin Hosen | 1068. Сумма | 11 ноя 2018 23:56 | 3 |
#include<stdio.h> int main() { int n, sum=0, i; scanf("%d", &n); if(n>0) { for(i=1; i<=n; i++) sum=sum+i; } else if(n<0) { for(i=n; i<=1; i++) sum=sum+i; } printf("%d", sum); return 0; } |
| Actually it just describes Euclid algorithm in a tedious way. | some_programming_novice | 1053. Пиноккио | 11 ноя 2018 10:21 | 1 |
|
| здавствуйте! | dainil | 1264. Трудовые будни | 11 ноя 2018 00:24 | 1 |
помогите понять условие, пожалуйста, буду благодарен |
| Why this is said "wrong" ? this is true. | Sadriddin | 1209. 1, 10, 100, 1000... | 10 ноя 2018 22:37 | 1 |
#include <iostream> #include <math.h> using namespace std; int main() { int n,k,i,a;float z; cin>>n; int *b; b=new int [n]; for(i=1;i<=n;i++){cin>>k;z=sqrt((k-1)*8+1);a=z;if(a==z)b[i-1]=1;else b[i-1]=0;} for(i=1;i<=n;i++)cout <<b[i-1]<<" "; return 0; } |
| хммм, что не то? what??? | dainil | 1001. Обратный корень | 10 ноя 2018 00:35 | 1 |
import math a=input().split() for i in range(len(a)): u=int(a[i]) l=str(math.sqrt(u))+'0000' for x in range(len(l)): if l[x]=='.': print(l[0:x+5]) Edited by author 10.11.2018 00:35 |
| oddiygina kichik harflarning ixtiyoriy ravishda to'ldirsangiz kifoya!!!! | Adhambek | 1219. Symbolic Sequence | 9 ноя 2018 15:52 | 2 |
Buning uchun rand() funksiyasidan foydalaning. masalan: 1000000 ta ababababbabab.....asdbasdsajkdbksajbdjkasbdkjbskfjbaksjdbfkjsad. faqat ixtiyoriy ravishda bo'lsin k = rand()%26 + 97 ; qilib chiqaring shuni uzi kifoya Edited by author 15.06.2013 11:32 |
| Python Wrong answer. Первый раз на этом сайте. Что не правильно? | Altynbek | 1001. Обратный корень | 9 ноя 2018 15:00 | 2 |
intxt = input() for i in intxt.split()[::-1]: print('%.4f' % int(i) ** 0.5) IIRC, Python's input() reads only one line. You should probably do this for every line in sys.stdin. Well, rarely do I write solutions in Python so I might be wrong. |
| For C++ Users | 0blivium | 1161. Stripies | 9 ноя 2018 03:58 | 1 |
Use the priority queue data structure. |
| WA #5, WA #6 | Spatarel Dan Constantin | 2096. Всё включено | 9 ноя 2018 01:22 | 1 |
input: 3 3 1 1 1 0 0 2 1 3 1 2 1 1 1 3 0 0 0 1 2 1 0 0 output: - - 1 |
| Runtime Error(access Violtion) HELP!! | Hrant Nurijanyan [RAU] | 1370. Волшебник | 8 ноя 2018 13:03 | 5 |
#include <iostream> #include <string> using namespace std; int main() { string a[3000]; int n; int m; cin >> n; cin >> m; for (int i = 0; i < n; i++) { cin >> a[i]; } int j = m; for (int i = 0; i < 10; i++) { cout << a[j]; j++; if (j == n ) { j = 0; } } cout << endl; return 0; } add ""cout<<flush;"" in diffrent places and see if it works(sometimes solves the error) string a[3000]; Hmm. It's really funny to use string array for containing int values. Edited by author 13.04.2014 14:08 1 ≤ M ≤ 32767. and you are trying to print a[j] which j >= m m can be above n; m can be above a length. To put big arrays on stack is a bad idea. a should be dynamic array or vector. |
| WHY WA3??? PLEASE HELP!!!! | BAron | 1370. Волшебник | 7 ноя 2018 19:49 | 12 |
I THINK THAT MY PROGRAM MUST HAVE AC BUT WA3 WHAT THE 3 TEST???? PLEASE POST TEST №3!!!!!!! Edited by author 13.05.2007 15:12 blonde :) ha ha. It is joke about WRITING MESSAGES WITH CAPS LOCK ON Which difference write messages WITH CAPS LOCK ON or with caps lock off? Please post some tests! I dont know why my program had WA :( 12 335 1 2 3 4 5 6 7 8 9 0 7 7 answer 7123456789 Thanks BAron 13 май 2007 15:06 Thanks for the test, I've got AC! #include <iostream> #include <algorithm> using namespace std; int main() { int i,n,m; cin>>n>>m; long int *a=new long int [n]; for(i=0;i<n;i++) cin>>a[i]; rotate(a,a+m,a+n); long int b[10]; for(i=0;i<10;i++) b[i]=a[i]; for(i=0;i<10;i++) cout<<b[i]; cout<<endl; return 0; } the test of Alias doesn't work,but why?What is incorrect in code? Already got AC....this code is right,you only need to decrease the quantity of ranges by decreasing the "m".......make m<n and everything will be ok ;) Or you can use "%" :) And yes,i'm necroposter ))) |