Общий форумTL1 with G++ but AC 0.015 with VC++ 2010? My solution is only 14 strings and only one cycle to read ai. Could anybody correct answers given by my Wa program: 1 3 2 5 3 5 4 7 5 7 6 8 7 10 8 12 9 13 10 13 11 14 12 15 13 17 14 19 15 20 16 23 17 21 18 22 19 15 20 24 21 26 22 18 23 30 24 32 25 32 26 31 27 23 28 33 29 13 30 35 31 37 32 39 33 29 34 42 35 43 36 44 37 43 38 44 39 45 40 46 41 47 42 48 43 34 44 39 45 54 46 56 47 58 48 48 49 27 50 57 Here are the correct answers: 1 3 2 5 3 5 4 7 5 6 6 8 7 10 8 12 9 11 10 11 11 8 12 15 13 14 14 17 15 20 16 23 17 18 18 20 19 15 20 24 21 24 22 18 23 21 24 32 25 19 26 27 27 23 28 31 29 13 30 35 31 22 32 39 33 29 34 35 35 40 36 44 37 30 38 33 39 42 40 44 41 31 42 45 43 32 44 39 45 50 46 43 47 44 48 60 49 27 50 39 Thank! Debugging in range[1..50] was enough for AC. Edit: Nevermind Edited by author 03.12.2009 01:15 Edited by author 03.12.2009 01:15 My ac program print only 500 when n=625. I think the test number is not good enough. I'm sorry.I use the wrong project. This is very important: "SMS message which consists of latin letters and spaces only can be up to M characters long while the length of SMS message which consists of any characters is limited by N characters." Because non-latin letters are coded by another charset and message header will took 5 extra bytes. Read the problem task about N and M you will understad; test case: 3 5 aaaa 答案是 1 3 5 aaa! 答案是 2 http://blog.csdn.net/zhangyanxing666/article/details/9831623I use Dynamics that originally need 31607*3400 operation for input 31607*31607, but when I notice that only first 114 prime numbers uses, and only first 8 of them with power more than 1, I reduce operation count to 200*31607. BTW it works smth about 3 sec. So I use preprocessing to solve it. Does exist another algorithm, or I need to optimize this one? (I think people, who ac this problem, guess algorithm by it complexity) Maybe that can help someone to solve... /* * Firstly note that according to the problem statement N is composite. * Then find smallest divisor M that N%M == 0 and let G = M/N. * Now we can factorize N as N = G*M = G*(a1 + a2 + ...) and consider * values G*a[i], gcd(G*a1, G*a2, ...) == G as the answer. Those values * will have the largest GCD. It can be easily proved that to maximize * LCM all a[i] must be coprime and be of the form prime^k. * Use dp to find such partition... */ But when N~ 10^9 and N - is prime number, than smalles divisor M = N, and G = N/M = 1. a[1] + a[2] + ...a[k] = M ~10^9 . how do use DP? N cannot be a prime number, it's always composite. Read the statement carefully > each box contained at least one hundred cartridges. > Anka noticed that there was the same number of cartridges in all boxes maybe it will be more correct to replace "in all boxes" with "in each box"? Edited by author 11.02.2012 17:56 Edited by author 28.02.2012 20:32 N cannot be a prime number, it's always composite. Read the statement carefully > each box contained at least one hundred cartridges. > Anka noticed that there was the same number of cartridges in all boxes maybe it will be more correct to replace "in all boxes" with "in each box"? Edited by author 11.02.2012 17:56 Thank you!!!!!!!!!! Hovewer, if M - is smalles divisor of N, than 1 < M < 31623 ! I Ac, with 0.046 s !! Edited by author 28.02.2012 22:19 Edited by author 28.02.2012 22:19Could you give me some hints about how to breakup a prime as m=a1+a2+a3... so that lcm(a1,a2,a3,...) is biggest? Please, write solve for N = 197*197... My result: 1576 1773 4925 1379 2167 2561 3349 3743 4531 5713 6107 197 197 197 197 197 All OK, I've got AC Can you give me some hints about how to breakup a prime as m=a1+a2+a3... so that lcm(a1,a2,a3,...) is biggest? Can you give me some hints about how to breakup a prime as m=a1+a2+a3... so that lcm(a1,a2,a3,...) is biggest? use ( > ), and don't use ( >= ). GOOD LUCK I have recently started programming,please help me. where is wrong in this program? It was compilition error. #include<iostream> #include<math> double b[500000]; int main(int argc, char* argv[]) { unsigned long long a,i=0,j; while(a!=EOF) {std::cin>>a; i++; b[i]=sqrt(a); } for(j=i;j>1;j--) std::cout<<b[j]; return 0; } how many do values enter in this program? I don't know . How do i work? you can use global array to solve it,but it should be large,at least 500000. for example : double answers[500000]. Did you find answer? Please,write here Adhambek. Edited by author 07.08.2013 17:53 please give me some tests Edited by author 07.08.2013 17:31 Test#8 -> N/3 == M and Holden is not hater => output is M*(N-M-1). Test#4 -> N/3 > M => output is '0'. what is the formula when n/3<m? My program is more advanced than LCA. It uses BFS and could work on arbitrary graphs. Could somebody help with this test? I know that if there is no bug with my program then there is a problem with connectivity of graph from start point to end point. Check for cases when start = end. also don't use incorrect comparison. for example: newPoint = point+delta if(0<=newPoint && newPoint<w*h) Double post, please remove this one. Edited by author 06.08.2013 17:09 Edited by author 06.08.2013 17:14 This is a big point I think should take care. this is my code in C++ but the system does not accept it. please help me. --------------------------------------------------------------- #include<iostream> using namespace std; int main() { long long int nums[100][100]; char x[90]; int n, m; long long int id, temp; cin>>n; for(int i=0; i<n; i++) { cin>>id>>m; nums[i][0]=id; nums[i][1]=m; } for(int i=0; i<n; i++) { for(int j=i+1; j<n; j++) { if(nums[j][1]>nums[i][1]) { temp=nums[j][0]; nums[j][0]=nums[i][0]; nums[i][0]=temp; temp=nums[j][1]; nums[j][1]=nums[i][1]; nums[i][1]=temp; } } } for(int i=0; i<n; i++) { cout<<nums[i][0]<<" "<<nums[i][1]<<endl; } return 0; } Edited by author 03.11.2012 14:25 It will get TLE, because it works in N^2. Такой вывод для первого теста подходит, т.к. "говорит" WA2 Console.Write("3 5\n26 4\n22 4\n16 3\n20 3\n1 2\n11 2\n7 1\n"); А этот WA1. В упор... =( . -------------------------------- using System; using System.Collections.Generic; class Program { struct TRec { public int ID, M; } static int Comp(TRec x, TRec y) { if (y.M < x.M) return -1; else if (y.M > x.M) return 1; else return 0; } static void Main() { int N = int.Parse(Console.ReadLine()); List<TRec> D = new List<TRec>(); string[] RecStr; for (int i = 0; i < N; i++) { RecStr = Console.ReadLine().Split(' '); TRec R = new TRec(); R.ID = int.Parse(RecStr[0]); R.M = int.Parse(RecStr[1]); D.Add( R ); } D.Sort(Comp); foreach (TRec X in D) Console.Write("{0} {1}\n", X.ID, X.M); Console.ReadLine(); } } Делаю в C#2012. Неужто в 2010 quick_sort работает по другому? hi! Need to use stable sort. I add extra field - ind, to compare 2 entry. using System; using System.Collections.Generic; class Program { struct TRec { public int ID, M, ind;} static int Comp(TRec x, TRec y) { if (y.M < x.M || (y.M == x.M && y.ind > x.ind)) return -1; if (y.M > x.M || (y.M == x.M && y.ind < x.ind)) return 1; return 0; } static void Main() { int N = int.Parse(Console.ReadLine()); List<TRec> D = new List<TRec>(); string[] RecStr; for (int i = 0; i < N; i++) { RecStr = Console.ReadLine().Split(' '); TRec R = new TRec(); R.ID = int.Parse(RecStr[0]); R.M = int.Parse(RecStr[1]); R.ind = i; D.Add(R); } D.Sort(Comp); foreach (TRec X in D) Console.Write("{0} {1}\n", X.ID, X.M); Console.ReadLine(); } } very strange, when using printf("%lld", ans); -> WA6 however, cout << ans << endl; ->AC same WA6 for me, but: printf("%I64d\n", answer); -> AC Обратите внимание на результат при N = 1000000000. А точнее на его размер 555555555888 в 32 бита он не поместится. 8 тест из-за этого выдает "Wrong answer". Hi i'm getting WA for #10, can anyone help with this? My code works for everything ive tested so far public static void main( String [] args){ int a,b; Scanner sc = new Scanner(System.in); a = sc.nextInt(); b = sc.nextInt(); int[] array = new int[b]; for( int i = 0; i < b; i++) array[i] = sc.nextInt(); int carry = 0; for( int i = 0; i < b; i++){ array[i] = array[i] + carry; if(array[i] > a) carry = array[i]%a; else carry = 0; array[i] = array[i] - carry; } int answer=0; array[b-1]+=carry; int current = 0; for( int i = 0; i < b; i++){ if(array[current] <= a){ array[current] = 0; current++; } else array[current] = array[current] - a; } for( int i = 0; i < b; i++) answer+=array[i]; System.out.println(answer);
} Edited by author 05.08.2013 14:55 Edited by author 05.08.2013 17:31 subj I didnt use ull & got AC. |
|