|
|
Common BoardЗдравствуйте подскажите пожалуйста. Почему не правельно ?? var c:integer; begin readln(c); if c in [0..4] then writeln('few'); if c in [5..9] then writeln('several'); if c in [10..19] then writeln('pack'); if c in [20..49] then writeln('lots'); if c in [50..99] then writeln('horde'); if c in [100..249] then writeln('throng'); if c in [250..499] then writeln('swarm'); if c in [500..999] then writeln('zounds'); if c in [1000..2000] then writeln('legion'); end. I really don't understand, why should I divide the answer by 8?.. UPD: Nevermind, got it. Edited by author 02.05.2014 17:23 In problem you are given full axis and if you don't want divide answer by 8, you must divide given a and b by 2 before counting integral Edited by author 06.10.2014 02:02 Edited by author 06.10.2014 02:02 BinaryMind, no, it's because your a and b is full lenght and width of ellipse, but you need half of a and half of b. import java.util.Scanner; public class ObratniyKoren { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub
int i; int n; Scanner scan=new Scanner(System.in); n=scan.nextInt(); long []a=new long[n]; for(i=1; i<n; i++) { a[ i]=scan.nextInt(); } System.out.println("выводим массив наоборот"); for(i=n-1; i>0; i--) { System.out.println((double)Math.sqrt(a[i]));
} } } Did you try to read FAQ? "The program must print only the data that is required by the problem statement. The program must not print any prompts (“Enter N:”). The program must not wait for pressing a key at the end of execution." Read the f...ing manuals before starting to use any service, including this one. Find the solution and explanation of this task in manyprogrammingtutorials.blogspot.com #include <iostream> #include <math.h> using namespace std; double len_points(double x1, double x2, double y1, double y2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); } int main() { const double pi = 3.14159; double sum = 0, arr[101][2], r; int n; cin>>n>>r; for(int i = 0; i < n; ++i) cin>>arr[i][0]>>arr[i][1]; for(int i = 0; i < (n - 1); ++i) sum += len_points(arr[i][0], arr[i + 1][0], arr[i][1], arr[i + 1][1]); sum += len_points(arr[0][0], arr[n - 1][0], arr[0][1], arr[n - 1][1]) + 2 * pi * r; printf("%.2lf", sum); return 0; } It is not recommended (check rules) to post problem solutions (especially if they are correct) in forum. Edited by author 05.10.2014 04:34 Don't post your code here, Harutyun. I wrote a e-mail to timus_support@acm.timus.ru about incompleteness of statements of some problems (1089 and 1934) and created posts in respective problems threads quite a while ago but didn't get any kind of feedback. Bugs in statements are still here. Does it mean letter were lost or someting? Edited by author 04.10.2014 22:40 I always WA at TEST9,who can give me a test like test9 ? other test in discuss were all used.It's right. What is the format of output, blank spaces before number? I have wa8 when I used float numbers, when I changed it to double I get ac. Never use float at ACM contests :) just forget this wrong word 'float' :) right words are 'extended' 'double' :) Great thanks to you! :) Really helpful! thank you very very much!!! import java.util.Scanner; public class Summa { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner scan=new Scanner( System.in); System.out.println("Введите значение a"); int a; a=scan.nextInt(); System.out.println("Введите значение b"); int b; b=scan.nextInt(); System.out.println(" a + b = " + (a + b)); } } You program outputs: Введите значение a Введите значение b a + b = 6 istead of just 6 Edited by author 03.10.2014 11:20I don't understand what's wrong? In my IDEA all works! import java.io.IOException; import java.util.Scanner; public class summa { public static void main(String[] args) throws IOException { Scanner s = new Scanner(System.in); int n = s.nextInt(); int[] mas = new int[n*n]; if(n!= 0) { for (int i = 0; i < n * n; i++) { mas[i]=s.nextInt(); } if(mas.length>1) { qSort(mas, 0, mas.length-1); for (int i = 0; i < mas.length; i++) { System.out.print(mas[i] + " "); } }else System.out.println(mas[0]); }else System.out.println("0 элемнтов"); } public static void qSort(int[] A, int low, int high) { int i = low; int j = high; int x = A[(low+high)/2]; do { while(A[i] < x) ++i; while(A[j] > x) --j; if(i <= j){ int temp = A[i]; A[i] = A[j]; A[j] = temp; i ++ ; j --; } } while(i <= j);
if(low < j) qSort(A, low, j); if(i < high) qSort(A, i, high); } } Edited by author 02.10.2014 20:36 Edited by author 02.10.2014 20:36 Any suggestions of the test? I rewrote solution from numerical to purely geometric, but still WA #10 and I can't find the reason. Can anyone provide with more tests? especially Test#3 ? (We) [are] {blind}, (we) [could not see] {creation of this clone army} It's not the easiest problem and I don't know good solution, but if I was on the olympiad and would have to solve the problem, I would just precalculate the answer. a difficult combinatorics problem. x1 + x2 +... + x10 = S with limitation: xi between ? , ? Need to fill an array COUNT[1..9][0..81] and answer is COUNT[9][S] Exclusion: if S == 1, then answer is 10 Edited by author 30.09.2014 22:13 Why "Time limit exceeded" ??? Edited by author 28.09.2014 09:03 Use G++ 4.7.2. G++ 4.7.2 C11 works wrong. I don't know about 2013, but C11 works fine now. import java.util.Scanner; public class Acm { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int[] a = new int[n]; int[] b = new int[n]; for(int j = 0; j < n; j++){ Scanner u = new Scanner(System.in); a[j] = s.nextInt(); b[j] = s.nextInt(); }
for(int p = 100; p >= 0; p--){ for(int q = 0; q < n; q++){ if(b[q] == p){ System.out.println(a[q] + " " + b[q]); } } } } } Edited by author 26.09.2014 23:34 hi,i know! there are some solution in this discussion that is a dangerous thing for someone that want to think more... so i say something about this problem for only hint.. for solving this problem this is better to check 2 or 3 example then consider a general case with n as input then try to simulate the answer and in the final step code it. be successful... I tried everything before I realized that my program should accept numbers like 1.e+1 even if there is no digits after '.'. Weird! I hope this information would be helpful to someone. |
|
|