Общий форум Edited by author 27.08.2016 13:09 Edited by author 27.08.2016 13:09 Try test with t = 8 and s >= 2 недавно столкнулся с проблемой того что необходимо сохранять некоторыерешения на компьютер если для этого какие нибуть програмки? Самое банальное-создать txt файл и скопировать АС-решение в него. Можно сохранить и в папке,где находится ваше ide( например FreePascal ). using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Soap; using System.IO; namespace _2033 { class Device { public string Friend { get; set; } public string Name { get; set; } public int Cost { get; set; } } class Program { static void Main() {
List<Device> objList = new List<Device>(); for (int i = 0; i < 6; i++) objList.Add(new Device { Friend = Console.ReadLine(), Name = Console.ReadLine(), Cost = int.Parse(Console.ReadLine()) });
// 1. Находим девайс, который находится у большинства парней var query = from list in objList group list by list.Name into grouping orderby grouping.Count () descending where grouping.Count()>=2 select new {grouping.Key,PRCNT= grouping.Count ()} ; string Device = ""; int prev_cnt = 0; bool isFind = true; foreach (var item in query) { if (prev_cnt != 0 && item.PRCNT == prev_cnt) { isFind = false; break; } else if (prev_cnt >= 2 && item.PRCNT<prev_cnt) break; Device = item.Key; prev_cnt = item.PRCNT; } if (Device != "" && isFind) { Console.WriteLine(Device); return; }
//Если таких устройств несколько , то находим самое дешевое из них var query2 = objList.OrderBy(dev => dev.Cost); foreach (var item in query2) { Console.WriteLine(item.Name); return; } } } } Samples: 1 201 405 Should be 99(2) + (3) 1 301 907 Should be 99(3) + (4) 1 448 2824 Should output something large, but the solution definitely exists :) Edited by author 26.08.2016 07:23 Sample numbers have different value of math.sqrt() in last digit. Why? This task is not so big level for hidden problem. sample result: 2297.0716 936297014.1164 0.0000 37.7757 my result: 2297.0715 936297024.0000 0.0000 37.7757 import java.io.PrintWriter; import java.util.Scanner; import java.util.*; public class AlgorithmTAsk { public static void main(String[] arg){ Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); ArrayList<Float> f = new ArrayList<Float>(); while (in.hasNextLong()) { f.add((float) Math.sqrt(in.nextLong())); } for(int i = f.size()-1;i>=0;i--){ out.printf("%8.6f\n",f.get(i)); } out.flush(); } } Edited by author 19.04.2016 19:45 Try double instead of float import java.util.Scanner; import java.text.DecimalFormat; import java.lang.StringBuffer; import java.lang.Math; public class Timus2{ public static void main(String[] args){ Scanner S = new Scanner(System.in); DecimalFormat df = new DecimalFormat("#.0000"); StringBuffer result = new StringBuffer(); while(S.hasNext()){ result.append(df.format(Math.sqrt(S.nextDouble())) + "\n"); } S.close(); System.out.println(result); } } 1) Any advantages of using "StringBuffer result"? Is it really faster then just print result line by line? 2) Show here expected output, your program output, compare. in prims algo implementation using priority queue, how can i decrease a key in priority queue ? you can't change the element. you have to make your own min-heap for the dijkistra I got AC on VB .NET 2010 !!! Write me on mail saucy_smile@mail.ru and I'll send you the source code :-) Edited by author 24.08.2016 08:07 Edited by author 24.08.2016 08:08 Please check the 12-th test. I and others thinks that our solutions are correct, but they are WA on 12... Maybe anyone can give a little hint? Edited by author 03.08.2006 16:49 Thank you! :) But it is not helped me. Maybe you give me this test? Or any similar? Yeah, I have WA12 too. I doubt if the test is really correct. And one more question: what means pluses and minuses in brackets? (Sorry for offtop). Edited by author 03.08.2006 22:16 Edited by author 03.08.2006 22:16 Cool men write (-) if there are only theme in post, and (+) if it consists any more than ony theme :) It seems that 12 test has cases like 1e14234320000000 2 Is that output would be correct for this case: 1.00e14234320000000 Edited by author 04.08.2006 01:42 12 test has cases like 1e-14234320000000 2 and correct answer for this case: 0.00 From my code: if( exp > 1000 ) ... // make Output Limit The result is Output Limit, test 12! So, exp is more than 1000 :) From problem statement: "It is guaranteed that a length of a result will not exceed 200 symbols." Is it right (with such big exp and number != 0)? No, that was bug in my check code. Later I submited smth like that: if (e>1000 && !isnull(mantissa)) while (1); and this code didn't cause tle. I had the code: if( abs( exp ) > 1000 ) ... // the answer is 0.0000... It got WA 12. Then I decided to divide it into two parts: exp>1000 and exp<-1000. if( exp < -1000 ) ... // 0.000... - 100%, yes? else if( exp > 1000 ) { // I amn't sure that there can be such a situation, that's why I do only output limit while( 1 ) cout << "111\n"; } Output Limit 12! "It is guaranteed the the length of output would be less than 200 symbols". I think, exp>1000 can be only when the number is 0 ( 0e10000 ). But then the right answer is 0.000 - the first code, which gets WA. So, there is a test in 12th test where exp>1000 and number is NOT 0! You forget that input file may contain a number of test cases. Maybe cases with big (and small) exponent your program processes correctly, but fails at other cases. Although i agree that it is very, very strange. There are tests like 1e+00000000000000001 5 or 1e-10000000000000000 2 First, my program had WA on test 12. Than I fixed my bug with this tests, and finally got AC=) my program processes correctly these cases, outputing: 10.00000 0.00 but still wa#12 Try this test: 1+10 0 # it's not a correct float number I got AC when add: if (Regex.Match(val, "[\\+\\-]?([0-9]*\\.)?[0-9]+([eE]?[\\+\\-]?[0-9]+)?", RegexOptions.Singleline).Value != val) { Console.WriteLine("Not a floating point number"); } No, the correct expression is @"^[+-]?([0-9]*\.)?[0-9]+([eE][+-]?[0-9]+)?$" without "?" after [eE] Your expression fails this test: 1+10 0 # The correct answer is "Not a floating point number" Hello! If you have WA 5, pay attention to the fact, that some programmer could take part in contests in more than 3 comands, even in all. Got AC if you WA #9 try this 0.00000000000e10 5 0.00000000001e10 5 I have WA #9 and I have tried this test. But my answer is correct: 0.00000 0.10000 Try this -0.0000010e+6 0 Correct answer is -1 Hello everybody! I wanted to share with you a little site that I made: http://acmtimusru.appspot.com with two additional ranklists: (1) countries ranklist: to compare countries between them by: rating, users, problems solved and activity = last ac; clicking on each country will get you to (2); (2) authors by country ranklist: to compare yourself with other people from your country. This site looks exactly like the acm.timus.ru site, with all links pointing to acm.timus.ru, except for the top red link that points to the countries ranklist. I hope you'll find this useful. I know this site will get deprecated as soon as the admins will create these ranklists on acm.timus.ru, but I had fun building it and learning something new (google app engine). Hello everybody! I wanted to share with you a little site that I made: http://acmtimusru.appspot.com with two additional ranklists: (1) countries ranklist: to compare countries between them by: rating, users, problems solved and activity = last ac; clicking on each country will get you to (2); (2) authors by country ranklist: to compare yourself with other people from your country. This site looks exactly like the acm.timus.ru site, with all links pointing to acm.timus.ru, except for the top red link that points to the countries ranklist. I hope you'll find this useful. I know this site will get deprecated as soon as the admins will create these ranklists on acm.timus.ru, but I had fun building it and learning something new (google app engine). Thank u so much... Great job, man. Hi! Can you share me your code? Or/And Can you tell me, every when update the lists? Thank you! My solution int main(){ //ios_base::sync_with_stdio(0); int l, r, t; cin >> l >> r >> t; cout << t * (l / r) << ' ' << t * (l/r + !(l % r == 0)) << endl;
return 0; } My solution falls on test 29. I have AC. My calculation of some values was wrong.:( If you have TL you should output line very effective (if you output one character you get TL). For pascal good output: s:string; setlength(s,n); s:='.......'; write(s). #include<iostream.h> #include<string.h> using namespace std; int main() { int number; cin>>number; string s; int i=0; for(;i<number;i++) { cin>>s; std::size_t find=s.find("puton"); std::size_t find1=s.find("one"); if((find != std::string::npos)||(find1 != std::string::npos)) cout<<"YES\n"; else cout<<"NO"; s.clear(); } //system("pause"); return 0; } Obviously you aren't testing all the words. You has to consider if the input string contains a substring that isn't (one/output/out/in/input/puton). I'll just add that test #1 for this problem is a pretty serious test that requires complete correctness, not just the samples to pass (unlike in other problems). Is it possible to buy several subscriptions? It's not forbidden, but it's never necessary for optimal solution. Each subscription for k or more concerts, you not need more then one. Just why? 4 1 1000 5 1000 5 1000 5 1000 5 2 10 You need to buy two identical subscriptions to get 3600. Ignore my post above, I misunderstood the problem statement. But still, even if you understand, i still don't. In case of 4 1 1000 5 1000 5 1000 5 1000 5 2 10 or even, if we're not allowed to use the same subscription twice, 4 2 1000 5 1000 5 1000 5 1000 5 2 10 2 10 , why can't we have 3600? That is, if i understood you correctly... Can you give me a hint about 8 test "If it turns out that the last cut should be made at the coordinate of exactly 1 meter, then, of course, this cut is not made." This code in Java: int v = 0; int n = 1998; while (buffer.length() > 1) { v += n; v %= buffer.length(); buffer.deleteCharAt(v); } Got AC in 0.109 time |
|