|
|
Общий форумAs I can see this statement is wrong: "Пиксели нумеруются от левого верхнего угла, по диагоналям, слева-направо и снизу-вверх". There should be "сверху-вниз". Am I right? No, you are not right. See one more time: 1 3 6 2 5 8 4 7 9 :) Edited by author 01.06.2013 22:05 Edited by author 02.05.2011 23:00 There is a method that you can find the solution with one loop. here is a hint: 1. if solution is s and sn is the number of s, then 2 * sn > n 2. if you delete any two different numbers until there is no different number, so this number is s.(because 2 * sn > n). And you can do deleting with one loop. good luck Thanks use quickSort and output [n/2] value... what is test case 7? I think my doing well. #include<stdio.h> int main() { int n,val[1001],pos1=2,pos2=1,sum[1001]; scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&val[i]); for(int i=2;i<=n-1;i++) { sum[i]=val[i-1]+val[i]+val[i+1]; } for(int i=2;i<=n-1;i++) { if(sum[i]>=sum[i+1]) { sum[i+1]=sum[i]; pos2++; } else if(sum[i]<sum[i+1]) { pos1+=pos2; pos2=1; } } printf("%d %d",sum[n-1],pos1); } I don't understand where I'm wrong. I tried the sample and the result is right! #include<iostream> #include<map> using namespace std; int main() { int n,num; map<char,int> val; val['a']=1;val['b']=2;val['c']=3;val['d']=3;val['e']=3;val['f']=3;val['g']=2;val['h']=1; val['1']=1;val['2']=2;val['3']=3;val['4']=3;val['5']=3;val['6']=3;val['7']=2;val['8']=1; char xy[1]; cin>>n; while(n--) { cin>>xy; num=val[xy[0]]+val[xy[1]]; if(num==6) num+=2; if(num==5) num++; cout <<num<<endl; } } import java.util.*; public class Penguins1585 { /** * @param args */ public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = Integer.parseInt(in.nextLine()); int a=0,b=0,c=0; for(int i=0; i<n; i++){ String s = in.nextLine(); String s1=s.substring(0,1); if(s1.equals("E"))a++; else if(s1.equals("M"))b++; else c++; }
if(a>=b && a>=c)System.out.print("Emperor Penguin"); else if(b>=a && b>=c) System.out.print("Macaroni Penguin"); else System.out.print("Little Penguin");
} } The question is simple. So is my code. See below It gets AC in VC++2000. But why does it get WA#1 in gcc4.7.2 and gcc4.7.2-c++11, until I replace the while-scanf loop with the commented while-cin loop? Thanks. -- #include <iostream> #include <cstdio> #include <cstdlib> #include <cmath> #include <vector> int main() { std::vector<long long> v; long long t; while (std::scanf("%lld", &t) != EOF) { // while (std::cin >> t) { v.push_back(t); } for (int i=v.size()-1; i>=0; --i) { printf("%.5f\n", sqrt((double)(v[i]))); } } In this test use LONG INT. I use INT and got WA, but later I use LONG INT and got AC. #include <stdio.h> #include <math.h> #define N 4 int main() { long double a[N]; long double b[N]; int i = 0; while(i < N) { scanf("%Lf",&a[i]); b[i]=sqrt((long double)a[i]); i++; } if(i == N) for(i= N - 1; i>=0; i--) { printf("%.4Lf\n", b[i]); }
} seems to return the right values. But writes "Wrong answer". Thanks! import java.util.*; public class Bifshteks //zadacha -1820 { int n; int k; int clock; public static void main(String args[]) { Bifshteks b = new Bifshteks(); Scanner in = new Scanner(System.in); System.out.println("Skolko bifshteksov zakazat? - "); b.n = in.nextInt(); while(b.n > 1000 || b.n<0 ) {System.out.println("Skajite zanovo . Vam Skolko bifshteksov zakazat? - "); b.n = in.nextInt(); } System.out.println("Skolko bifshteksov mojet gotovitsia odnoremenno? - "); b.k = in.nextInt(); int y = b.n/b.k; int x = b.n-(y*b.k); if(x==0) y+=0; else y+=1; System.out.println("Vaw zakaz budet gotov cherez "+y*2+" minut."); } } Обратите внимание на постановку задачи: "В единственной строке через пробел записаны целые числа n и k (1 ≤ n, k ≤ 1000)." В Вашем случае одновременно 2 целых числа ввести нельзя. "...solutions for which the outcome has changed." Is the outcome change "WA 6" -> "WA 8" a real change on which a letter is sent? Or only outcome code (WA, AC, ...) make sense, not a test number?? Edited by author 10.10.2009 14:54 Edited by author 10.10.2009 14:54 sorry, the condition contains the answer it's both change in code and change in test number. Help me find a mistake using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace курсач_1196 { class Program { static void Main(string[] args) { int n1 = int.Parse(Console.ReadLine()); int[] a = new int[n1]; for (int i = 0; i < n1; i++) a[i] = int.Parse(Console.ReadLine()); int n2 = int.Parse(Console.ReadLine()); int[] b = new int[n2]; for (int j = 0; j < n2; j++) b[j] = int.Parse(Console.ReadLine()); Array.Sort(a); int[] ab = a.Intersect(b).ToArray(); Console.WriteLine(ab.Length); } } } Please help pass the test 6. It is very necessary. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace _1910 { class Program { static void Main(string[] args) { string str = Console.ReadLine(); int n = int.Parse(str); string[] mas = Console.ReadLine().Split(' '); int[] a=new int[n]; for (int i=0; i<n; i++) a[i]=int.Parse(mas[i]); int sum=0, j=0, maxsum=0; if (n >= 3) { for (int i = 0; i < n - 2; i++) { if ((a[i] == a[i + 1]) && (a[i] == a[i + 2])) { sum = a[i]*3; j = i + 2; } if (sum > maxsum) { maxsum = sum; sum = 0; } } } Console.WriteLine(maxsum + " " + j); } } } Can anyone help me ? I have WA16 and i don't know what is wrong with my code . UPD : Test 16 is a big test . I replaced in one place int with long long and i got AC. Good Luck :) ! Edited by author 25.05.2013 14:23 5 3 4 5 0 4 0 1 4 0 1 2 3 0 1 0 What are the values of input in it? Can someone give me the test #7. I've got WA in this test. Thank's. Please try for the test: 2 2 1 2 2 1 The correct answer: 2 It seems that my program gives right answers to all tests, but, nevertheless, WA #2 :((( 1)check better names 2)find all distance 1 - 2 1 - 3 .... 69 - 70 and after try find a b c L[a,b] + L[b,c] < L[a,c] P.S. if 1 and 2 correct check you constans But I have WA #2. All constants are correct, and I use Floyd-Worshall to find all distances. Mysterious WA... Edited by author 26.10.2008 21:06 Did you find the problem? I also use Floyd-Warshall, but WA2. TL for this problem is 0.5s but list of successful submissions contains times up to 2s. |
|
|