|
|
Common BoardGetting WA on test 25, any test case? По условию, при входных n = 1 и единственном отрицательном значении ответ должен быть 0, но accepted получается и при неправильном решении такого теста... Либо я чего-то не понимаю... The test was added. Thank you. Input: 1a 1a 1a 1a 1a 1a 1a 1a 1a 1b 3b 5b 1c 1c Output: Tenpai what is wrong? #include <iostream> #include <cmath> #include <map> #include <vector> using namespace std; int main() { int n; string str; cin >> n >> str;
int k = str.size(); int i = 0; int sum = 1; if(n % k == 0) { while(i != n / k) { sum *= n - k * i; i++; } } else { while(i != n / k + 1) { sum *= n - k * i; i++; } sum *= n % k; }
cout << sum << endl;
return 0; } Edited by author 31.12.2015 12:38 It would be great if you stop searching telepathists and show error message. Is it compilation error? Add "#include <string>" line. Is it WA? Strange. Code looks working. Is it any another error? Show it. WA #10 Some people suppose n can be 20 so int is not enough for sum. Try to use long long sum. WA #10 Test: 5 !!! answer 10, your answer 20 5!!! here k=3, 5 isn't divisible by 3 so you have to multiply 5%3=2 with 5*(5-3) so the answer is 5*2*2=20 #include<iostream> //#include<string> using namespace std; int main() { int n; string s; cin>>n; cin>>s; int sum=n; int len = s.size(); //cout<<len<<endl; int i =1; while((n-i*len)>1) { sum*=(n-i*len); i++; } if(n%len!=0) cout<<(sum*(n%len))<<endl; else cout<<sum*len<<endl; return 0; } th: deleting leafes doesn't change centers BFS gave TLE 7. DFS must be much more successful. Reasons: 1) Easy to construct the son. 2) Easy and without memory reconstruct the father. DFS-TLE10 Therefore exists some strong mathematics in the problem to speed up algos. Edited by author 18.11.2008 09:24 There exists very strong pruning idea, which makes brute-force extremely fast =) Yes, DFS is the way for this problem. My AC 0.015 solution can solve a 20x20 in about 700 recursions. Here's a hint for the problem: Pay close attention to the following sentence: "If the number of bacteria in a certain cell becomes 5, then 4 of them die because of overcrowding.". What would happen if this rule didn't exist? Example 1: WHAT?????????????????????? Example 2: ?????????????????????? And... What is the answer? Example 1: WHAT?????????????????????? result: What?????????????????????? Example 2: ?????????????????????? result: ?????????????????????? These tests might cause runtime error if there're not all conditions observed in the code. Got AC just when passed these tests, thanks Try this: aaaaa...??? aaaa aaaaa.....!!! aa right answer: Aaaaa...??? Aaaa aaaaa.....!!! Aa "You are given Angela's message, which consists of uppercase English letters,..." -> Just uppercase letters in input. I spent 5+ hours trying to understand why I am having WA#9. DON'T use high level classes/methods like Console.Write/StreamReader/StreamWriter. Process input and send to output as raw bytes. I didn't find what was the issue (I am already tired with this shit), but I suppose StreamWriter or StreamReader can mess up with \r \n characters in some cases. Here is code example for WA#9. I use Console.OpenStandardInput(0) as input, and Console.OpenStandardOutput(0) as output. private static void SolveStateMachine(Stream input, Stream output) { using var writer = new StreamWriter(output, Encoding.ASCII, 1024); void Write(char ch) { writer.Write(ch); } void WriteS(string str) { writer.Write(str); }
... } When I change about code to below, I am getting AC: private static void SolveStateMachine(Stream input, Stream output) { void Write(char ch) { byte[] buffer = new byte[1]; buffer[0] = (byte)ch; output.Write(buffer, 0, 1); } void WriteS(string str) { byte[] buffer = Encoding.ASCII.GetBytes(str); output.Write(buffer, 0, buffer.Length); }
... } I got it. Test#9 is about characters with code >= 128. I was using Encoding.ASCII in C#, which causes replacing of all such characters with '?'. If your high level classes use UTF-8 encoding by default, you will also have problems. intput 4 0 333 0 777 output 0 I'm getting runtime error(access violation) on test case three. I don't know where I went wrong. Can anyone please help me? Here is my code using namespace std; #include <iostream> #include <cmath> #include<bits/stdc++.h> long long int n,m; bool vi[1005][1005], di[1005][1005]; float dp[1005][1005]; #define inf 1e7 float shortest_path(int x, int y){//returns shortest path //base case if(x==n && y==m) return 0.0; if(x>n || y>m) return inf; //memorization if(vi[x][y]) return dp[x][y]; //recursive relation float a,b,c = 20000.0; if(di[x][y]==1){ a = sqrt(c) + shortest_path(x+1,y+1);//diagonal b = inf; }
else { a = 100.0 + shortest_path(x+1,y);//left b = 100.0 + shortest_path(x,y+1);//up }
float ans = min(a,b); dp[x][y] = ans; vi[x][y] = 1; return dp[x][y]; } int main(){ cin>>n>>m; int k; for (int i = 0; i < n*m; ++i) { for (int j = 0; j < n*m; ++j) { di[i][j] = 0; vi[i][j]=0; dp[i][j]=0; } } cin>>k; for (int i = 0; i < k; ++i) { int a,b; cin>>a>>b; di[a-1][b-1] = 1; } cout<<round(shortest_path(0,0))<<endl;
} check that (r - l) % 2 == 1 Just calculate all possible sums. Then try to find some sum-n in this sums Got it. Never mind. It was simply a 12 digit input which is already prime. :) This problem is quite easy. Easier than a lot of problems with much less rated difficulty. I've already run throw every test i've found here and some that I thpught myself. I dont understand what is test #23. Can someone post some test to run? Edited by author 08.03.2021 04:25 Edited by author 25.03.2021 12:41 hi how is this issue in java programming language. please help /** * @author koti4 * */ import java.util.*; public class Main { /** * @param args */ public static void main(String[] args) { Scanner input = new Scanner(System.in); int k,n,x,y,flag=0; char x1,y1; String s = " "; n=input.nextInt(); for(int q = 0;q<n;q++) { s=input.next(); x1=s.charAt(0); y1=s.charAt(1); x = (int) x1-96; y = (int) y1-48; /*System.out.println(x); System.out.println(y);*/ for(int i =-2;i<=2;i++) { for(int j=-2;j<=2;j++) {
if (j != i) { if(x-i>0 & y-j>0 & x-i < 9 & y-j < 9) { if(i*i+j*j==5) { flag++; } } } } }
System.out.println(flag); flag = 0; } input.close(); } } journ = [] x = 0 k = 0 sold = 0 cmd = ',,' while cmd[0] != 'QUIT': cmd = input().split() oper_name = cmd[0] if cmd[0] == 'BID': x = cmd[1] journ.append(x) elif cmd[0] == 'DEL': x = cmd[1] journ.remove(x) elif cmd[0] == 'SALE': x = cmd[1] k = int(cmd[2]) for i in journ: if float(i) >= float(x): k -= 1 sold += 1 else: continue print(sold * 0.01) What is wrong ? Can I use CompletePack to solve it? Give me a test about wa15. 5 8 a 11 1.1 b 14 1.4 c 15 1.5 e 15 1.5 f 20 2.0 5 8 a 11 1.1 b 14 1.4 c 15 1.5 e 10 1 f 20 2.0 Input: _123 My first solution output: _<span class=number>123</span> My second solution output: _123 But all passed. So which answer are correct? Task description says: "The correct source of a program in Pascal is given" Your input is definitely not correct source .I'm already tired of solving this number..Mods please give me 19th test case... |
|
|