Common Board#include<iostream> #include<iomanip> #include<math.h> using namespace std; double a[10001]; int main() { int l=0,i,n,k; double x,m; cin>>n>>m; for(i=0;i<m;i++) { cin>>k; a[k]++; } for(i=1;i<=n;i++) { x=a[i]/m; x*=100; if(ceil(x)==floor(x))cout<<x<<".00%"<<endl; else cout<<setprecision(4)<<x<<'%'<<endl; } return 0; } Edited by author 09.04.2008 22:50 I have this Problem too. plz help, my program is been written in JAVA. Edited by author 13.10.2011 16:36 So, I have this problem too. What is the rigth solution? --- I found the answer, use Console.WriteLine("{0:f2}%", t); Edited by author 25.10.2012 19:37 Edited by author 25.10.2012 19:37 Try these inputs: 2 11 1 2 2 2 2 2 2 2 2 2 2 I change this >> first multiply 100 and then divide m . and it works. Check if the order RTLB is respected and pay attention to the fact that the matrix in the problem is inversed in comparison to the one that you build i.e. the bottom is curr_row - 1 and top is curr_row + 1. whats problem on test 3?? что за проблема на 3 тесте?? Yep Why my code get WA3? #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <vector> #include <cstring> #include <set> #include <map> #include <cmath> #include <algorithm> using namespace std; #define ll long long const ll nmax = 100005; const ll inf = 1234567890123; ll A, B, C; ll X, Y, Z; int main() { cin>>A>>B>>C; cin>>X>>Y>>Z;
if(Z > C) cout<<"There are no miracles in life"; else { ll ess = (ll)0; if(X > A) ess += X - A; if(Y > B) ess += Y - B; if(C - Z >= ess) cout<<"It is a kind of magic"; else cout<<"There are no miracles in life"; }
return 0; } or more simple #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <vector> #include <cstring> #include <set> #include <map> #include <cmath> #include <algorithm> using namespace std; #define ll long long const ll nmax = 100005; const ll inf = 1234567890123; ll A, B, C; ll X, Y, Z; int main() { cin>>A>>B>>C; cin>>X>>Y>>Z;
if(X > A) C -= (X - A); if(Y > B) C -= (Y - B); if(Z <= C) cout<<"It is a kind of magic"; else cout<<"There are no miracles in life";
return 0; } Notice that "Filling value” is THREE decimal places. Why always getting mle on #2 Hi. Can you give some samples to help fixing WA on test #7? Try using constant with higher precision. Edit: I know that author may not need this hint anymore, but I replied in case anyone was in the same trouble. Edited by author 18.07.2021 21:38 Edited by author 18.07.2021 21:38 What can you tell me about this test? I'm having WA all the time Same question. I tried all tests of this problem's forum and still got WA3. Edited by author 25.02.2013 21:48 just try 5 -5 0 0 1 1 2 2 3 4 5 3 4 10 49000 0 0 a = list(map(int,input().split())) n = len(a) for i in range(n-1,-1,-1): print("%.4f" % pow(a[i],1/2)) pow(a,b) in Python means the power of integer a and integer b (a^b) use a**b in Python instead. #include <iostream> #include <vector> #include <cassert> #define cpuid(func,eax,ebx,ecx,edx)\ __asm__ __volatile__ ("cpuid":\ "=a" (eax),"=b" (ebx),"=c" (ecx),"=d" (edx):\ "a" (func)); int main() { { int a,b,c,d; cpuid(1,a,b,c,d); int extended_model = (a & 0xF0000) >> 12; assert(extended_model == 4 << 4); int family = (a & 0x0F00)>>8; assert(family == 6); int model = (a & 0xF0)>>4; assert(model == 15); int stepping = a & 0xF; assert(stepping == 1); if (__builtin_cpu_is("broadwell")) { std::vector<char>((1ULL << 20)); } } int a, b; std::cin >> a >> b; std::cout << a + b << std::endl; } You're right. The CPU on the judging machine is Intel Xeon E5-2680 v4 (Broadwell). We updated the site news. Thanks for catching this. goto if if: print 123 not bad Edited by author 17.07.2021 18:23 using System; namespace a { class Program { static void Main(string[] args) { int n = Convert.ToInt32(Console.ReadLine()); double[] A = new double[n]; double S = 0; for (int i = 0; i < n; i++) { A[i]=Convert.ToInt64(Console.ReadLine()); } for (int i = 0; i < n; i++) { S = S + A[i]; } double B = S / n; for (int i = 0; i < n; i++) { if (A[i] == 3) { Console.WriteLine("None"); goto finish; } } if (B >= 4.5) { Console.WriteLine("High"); goto finish; } for (int j = 0; j < n; j++) { if (A[j] == 5) { Console.WriteLine("Named"); goto finish; } } Console.WriteLine("Common"); finish: ; } } } DP[i][j][k] = count of sets of length i ending at number j with total gcd of k initialize with dp[1][n][n] = 1 for every n >= 2 && n <= s ans is summation of all dp[K][num][g] where g > 1 and num between 2 and s Edited by author 16.07.2021 18:48 Edited by author 16.07.2021 18:48 Edited by author 16.07.2021 18:48 Show please 5 test! I have on this WA too ( Mb you forgot to sort your array or vector before start printing anything #I don't know why i start from lk+7. If anyone knew about that, please notify me. import sys n,k = sys.stdin.readline().split() n = int(n) lk = len(k) res = 1 for i in range(lk+7,-1,-1): t = n - i*lk if t>0: res *= t sys.stdout.write("%d\n"%res) Edited by author 16.07.2021 09:03 If you have WA on test #3 or on test #1 or on test #2 you must use DP! Else if you have WA on test #4 you must use unsigned int or int 64 or long. If you have WA on test #8 you must change start and finish points ( 6-2 and 2-6 is equal ) !^_^! Thanks a lot for WA 8.I got AC.^^ Thank you. I got WA at #8.And I have ACed now; Thank you from reminding! Thank you for your suggestion Thank you very very much! thx a lot!! If you have WA8 and use Binary Search - check that it work properly, i.e. return far station instead of nearest Edited by author 03.12.2010 00:05 thank u very much for the 2nd suggestion. first i got wa4 and then wa8..your message help a lot! thank you. Thanks a lot for WA #8! It's really tricky. first i got wa14 and forgot to use long long.your message help a lot! thank you. l1=[] l2=[] l3=[] for i in range(0,1000): l3.append(False) def funct(a): b=a.split() if b[0]=='register': if b[1] not in l1: l1.append(b[1]) l2.append(b[2]) print("success: new user added") else: print("fail: user already exists") elif b[0]=="login": if b[1] not in l1: print("fail: no such user") else: k=l1.index(b[1]) if l3[k]: print("fail: already logged in") else: if l2[k]==b[2]: l3[k]=True print("success: user logged in") else: print("fail: incorrect password") elif b[0]=="logout": k=l1.index(b[1]) if l3[k]: l3[k]=False print("success: user logged out") else: print("fail: already logged out") f=int(input()) for m in range(0,f): n=input() funct(n) f**king time limit!!! List is O(n) lookup, while dict is O(log n), so use that using DP you can achieve O(n) |
|