Общий форумFor 2 4 it should be days 2 and 4. For 100 200 it shoould be 100, 102...148(count must be 25 already)...200(count is 51). Janus brokes fuses every ODD day. There is 1 odd day in interval [2..4] Hmm... I see that I just did not understand the task clearly. For me it was like day 2 is the first day, but it is just the starting point of counting... Thanks. I used the formulas with phi and solved a system of 2 equations to get the coefficients, in python using floats. Any hint why I get WA8? all tests on the forum work. I eventually got AC by trying out several values around the integer the math formula gave and checking each against given initial values. Hello! Why I got WA? I can't understand :| IMO this must work... Tnx all. ---------------------------------------------------- dayTotal = (LastDay - FirstDay) + 1; for(counter = 1; counter <= dayTotal; counter++) { n = counter % 2; if(n != 0) fuse++; } ----------------------------------------------------- #include <iostream> int main() { int a,b; int answer=0; std::cin>>a>>b; if(a%2==0)a++; for(int i=a;i<=b;i+=2) answer++; std::cout<<answer; return 0; } JDBaha your solution is wrong. for 2 4 it says 1. Edited by author 15.10.2016 15:10 Edited by author 15.10.2016 15:10 I think it takes first player 5 turns to get '*', and 3 turns to move outside,it is at least 8 turns. why is 5 turns? Wrote on Pascal: var i, j: integer; ms, a, b: integer; arrg: array of integer; begin Read(ms); SetLength(arrg, ms);
for i := 0 to arrg.Length - 1 do begin var temp: integer; Read(temp); arrg[i] := temp; end;
for j := 1 to arrg.Length - 1 do for i := 1 to arrg.Length - j do if arrg[i - 1] > arrg[i] then Swap(arrg[i - 1], arrg[i]);
a := arrg.Length div 2;
for i := 0 to a do b := b + arrg[i] div 2 + 1;
Write(b); end. Wrong answer ( test 1 ). arrg.Length it may be odd long ans[] = new long[23]; ans[2]=lim[2]; for (int i=4; i<=20; i+=4) { int half=i/2; ans[i]=lim[half]*lim[half]; ans[i+2]=lim[half]*lim[half+2]; } System.out.println(ans[N]); lim stands for the "lucky in Moskva" Как узнать заранее, сколько выделять ячеек для решета? > Then k positive integers follow (one in each line). The numbers don't exceed 15000. So you will be asked for not more then 15000th prime. You can find it by brute force, by some prime table etc. My AC program thinks it is 163841. It looks like something is wrong with tests. Test 2 is the second sample but the answer 6 is not accepted! #include <bits/stdc++.h> using namespace std; const int N = 112345; int a[N]; int b[N]; main() { string s, t; cin >> s; int cnt = 0; int mx=0; int l=0; int cnte=0; for(int i = s.size() - 1; i >= 0; i --) { t = s[i] + t; a[0] = 0; for(int j = 1; j < t.size(); j ++) { int x = a[j - 1]; while(x > 0 && t[x] != t[j]) x = a[x - 1]; if(t[x] == t[j]) x ++; a[j] = x; mx = max(mx, a[j]); } b[i]=mx; if(mx==0)cnte++; mx=0; } if(cnte==s.size()){cout<<s;return 0;} else for(int i=0;i<s.size();i++){if(b[i]>=1)cout<<s[i];} } // any suggestion guys I have no idea what can be the fifth test thanks in advance 6 2 2 10 11 16 16 21 32 33 maybe this? 8 3 2 10 10 11 16 16 18 21 39 32 33 10 11 18 16 16 2 10 21 AC java 0.14 = for (int i=0; i<R; i++) { int retcode = s(i); if (retcode==-1) { i=-1; } } int s(int row) { .. //some backtracking call bt(list_of_added, left, r) .. if (errorwith_this_row) {//error row will be processed first, reprocess all rows int reg = L[r]; for (int i=r; i>0; i--) { L[i]=L[i-1]; } L[0]=reg; return -1; } .. return 0; } bt(list_of_added, left, r) { if (list_of_added.size=0) return -1; index=list_of_added.removelast left+=l[index]; //greedy adding itemd to list_of_added, decrease 'left'
if (left>0) bt(list_of_added, left, r);
} also i use marked[] with indexes of rows were needed, i use Lorig[], L[] (sorted Lorig[]) and id[], and ID[] (indexes of original lengths in Lorig) Can you give me a test for wa 7, please? seems like problem with precision import sys import math string = sys.stdin.read() def string_parsing(string): result = [] str = '' for j in range(len(string)): if string[j] != ' ' and string[j] != '\n': str += string[j] elif str !='': result.append(str) str = '' return result list = string_parsing(string) list = [round(math.sqrt(float(elem)), 5) for elem in list] list = ["{0:.5f}".format(elem) for elem in list] for i in range(len(list)): sys.stdout.write(str(list.pop()) + '\n') #What's wrong? Edited by author 12.10.2016 16:17 6 0 0 5 -10 10 -10 5 -5 10 -5 20 0 7 1 2 10 2 3 30 3 5 20 5 4 20 4 2 20 3 6 10 1 6 7 ans: 17 1 2 10 2 3 30 3 5 20 5 4 20 4 2 20 3 6 10 1 6 7 Is this output acceptable? Or do we have to remove flow cycles? update: got ac without removing cycles. Edited by author 13.10.2016 06:41 What is in test 4? I have WA and I dont know what is wrong. Personally I had problem with modular arythmerics I did it! I have TL 15 for a long time, but now I solved the problem. I use treap with gcd, but treap has a big constant and gcd works for O(log), so I write binary algorithm of calculating gcd instead of Euclid and it works! What algorithm did you use for gcd? can you paste only the gcd code here? hello,i got wa3.can you tell me why?or give me some tests.thank you very much! the source: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Timus1003 { class Program { static void Main(string[] args) { System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; List<Phone> arrayList=new List<Phone>(); while(true) {
string phoneNumber=Console.ReadLine(); if(phoneNumber=="-1") { break; } Phone phone = new Phone(); phone.PhoneNumber =phoneNumber ; phone.Size =Convert.ToInt32(Console.ReadLine()); string[] dics = new string[phone.Size]; int n=0; while(n<phone.Size) { dics[n] = Console.ReadLine(); n++; } phone.Dics = dics; arrayList.Add(phone); } // Console.WriteLine("out"); for(int i=0;i<arrayList.Count;i++) {
Phone phone = arrayList[i]; phone.Dics = phone.Dics.OrderByDescending(s => s.Length).ToArray<string>(); String[] str = new String[phone.Dics.Length]; for(int j=0;j<phone.Dics.Length;j++) { str[j] = wordToNumber(phone.Dics[j]); } phone.HasSolution=find(phone.PhoneNumber, str, phone); if(phone.HasSolution) { string solutionStr = ""; for(int k=0;k<phone.Solutions.Count;k++) { if(k==phone.Solutions.Count-1) { solutionStr = solutionStr + phone.Solutions[k] + ""; } else { solutionStr = solutionStr + phone.Solutions[k] + " "; }
} Console.WriteLine(solutionStr); } else { Console.WriteLine("No solution."); } } Console.ReadLine();
} public static bool find(string phoneNumber,string[] dics,Phone phone) {
for (int i = 0; i < dics.Length;i++ ) { // if (phoneNumber == "") return true; if (phoneNumber == dics[i]) { phone.Solutions.Add(phone.Dics[i]); //Console.Write(phone.Dics[i] + " "); return true; }
if (phoneNumber.IndexOf(dics[i]) == 0) { phone.Solutions.Add(phone.Dics[i]); // Console.Write(phone.Dics[i] + " "); string newPhoneNumber = phoneNumber.Substring(dics[i].Length); if(find(newPhoneNumber, dics, phone)) { return true; } else { phone.Solutions.RemoveAt(phone.Solutions.Count-1); continue; }
}
} // Console.WriteLine("No solution."); return false; }
public static string wordToNumber(string word) { char[] wordArr = word.ToCharArray(); char[] numArr = new char[wordArr.Length]; for (int i = 0; i < wordArr.Length;i++ ) { numArr[i] = charToNumber(wordArr[i]); } return new String(numArr); } public static char charToNumber(char mychar) { switch(mychar) { case 'i': case 'j': return '1'; case 'a': case 'b': case 'c': return '2'; case 'd': case 'e': case 'f': return '3'; case 'g': case 'h': return '4'; case 'k': case 'l': return '5'; case 'm': case 'n': return '6'; case 'p': case 'r': case 's': return '7'; case 't': case 'u': case 'v': return '8'; case 'w': case 'x': case 'y': return '9'; case 'o': case 'q': case 'z': return '0'; default: return mychar; }
} } class Phone { string phoneNumber; public string PhoneNumber { get { return phoneNumber; } set { phoneNumber = value; } } int size; public int Size { get { return size; } set { size = value; } } string[] dics; public string[] Dics { get { return dics; } set { dics = value; } } List<string> solutions = new List<string>(); public List<string> Solutions { get { return solutions; } set { solutions = value; } } bool hasSolution; public bool HasSolution { get { return hasSolution; } set { hasSolution = value; } } } } If I understood your algorithm properly, you intent to get best result with sorting you dictionary by word length and trying words from longest to shortest, but it's not always true. For example, let's test contains words with lengths 5 3 2 1, and proper results are 5-2-1 and 3-5. Your algorithm will find the 5-2-1, and not 3-5. (It was my mistake too and I got WA3 as well.)))) #include<stdio.h.> #include<string.h> #include<math.h> int main() { double len=0; int n,r,i,j; scanf("%d %d",&n,&r); double a[200][2]; for(i=0;i<n;i++) for(j=0;j<2;j++) scanf("%lf",&a[i][j]); for(i=1;i<n;i++) len=len+sqrt((a[i][1]-a[i-1][1])*(a[i][1]-a[i-1][1])+(a[i][0]-a[i-1][0])*(a[i][0]-a[i-1][0])); len=len+sqrt((a[i-1][1]-a[0][1])*(a[i-1][1]-a[0][1])+(a[i-1][0]-a[0][0])*(a[i-1][0]-a[0][0])); len=len+3.141*2*r; printf("%.2lf",len); fflush(stdin); getchar(); return 0; } I guess the 8th and 9th line. The value of radius is a real number instead of an integer, which is considered to be with decimal point. Thus "double r;" "scanf("%d %lf", ..)" maybe works. Also note. Is pi=3.141 accurate enough? I used 3.14159 in my AC program First I got WA#11 . Found that a simple increase of size of array to 20005 gave AC #11. Now I'm stuck in #15. Anyone have a case? #include "stdio.h" int main() { int n,i; scanf("%d %d",&n,&i); if(n==2) {printf("0"); return 0; } if(i<=n/2) printf("%d",n-i-2); else printf("%d",i-1-2); } #include "stdio.h" #include "stdlib.h" #include<string.h> int main() { long int m,n,sum=0,a[3001]; scanf("%ld %ld",&n,&m); for(int i=1;i<=m;i++) { scanf("%d",&a[i]); } n=n*3; for(int i=1;i<=m;i++) { sum+=a[i]; if(sum>=n) { printf("Free after %d times.",i); return 0; } } printf("Team.GOV!"); } |
|