Общий форумCode in C#!!! first of ALL just print and reverse print .... 3 times static string [,] reverse(string[,] arr) { string[,] tmp = new string [4,4];
for (int i = 0; i < 4; i++) { for (int j = 0; j < 4 ; j++) { tmp[i,j] = arr[4-j-1,i]; } } return tmp; } in this case i wrote code for 4x4 array!!! you can change your code to tmp[i,j] = arr[3-j,i] if u want reverse nxn array change all 4 to n GooD Luck! sorry for my english!! Edited by author 17.10.2012 02:39 Look how to use STL algorithm rotate(). It's very easy: rotate(arr, arr + k, arr + N); Thanks !!! I think it will be helpful in the future. ok... if the player 2 wins, then stop showing the second line? pls give help yes. input : 3 output: 2 good luck! what i have to do ?!! P( i<1> , i<2> , i<3> , ... , i<n-1> , i<n> ) determines at which position is the X[ i<1> , i<2> , i<3> , ... , i<n-1> , i<n> ] element in ( lets say ) RAM . And the Function P is absolutely correct. You should determine the dimensions k<1> , k<2> , k<3> , ... , k<n-1> , k<n> of the X for the given D elements. I don't know whether I could explain it, if not I'm really sorry ! I can't do much. :( Edited by author 16.10.2012 23:40 Edited by author 16.10.2012 23:39 teach=Int32.Parse(Console.ReadLine()); String[] arrTeach = new String[teach] for (Int32 i = 0; i < teach; i++) arrTeach[i] = Console.ReadLine(); //It no worked correct on timus compiler! Why? Console.ReadLine() return string You should just parse to int for (long i = 0; i < M; i++) { arrS[i] = long.Parse(Console.ReadLine()); } in your case arrTeach[i] = int.Parse(Console.ReadLine()); good luck with C# :) Sorry for my English Can anybody help me with WA 4? My program passes all tests given in discuss... Silly mistake, as usually. Incorrect number of zeros. Try this test: 100 Answer: 3 91 + 9 = 100 95 + 5 = 100 100 + 00 = 100 Somebody can get "50 + 50 = 100". It's wrong by problem. =). Edited by author 16.10.2012 18:52 #include<stdio.h> int main() { int N; scanf("%d", &N); int start; scanf("%d", &start); int sum = 1; for(int i = 1; i < N; i++) { int a; scanf("%d", &a); if(a == start) { sum++; } else { printf("%d %d ", sum, start); start = a; sum = 1; } } printf("%d %d ", sum, start); return 0; } #include<stdio.h> main() { int a, sum=0; scanf("%d",&a); if(a<0&&a>=-10000) { int i; for(i=a;i<=1;i++) { sum=sum +i;
} printf("%d",sum); } else if( a>=0&&a<=10000) { int i; for(i=1;i<=a;i++) { sum=sum +i; } printf("%d",sum);
} }
when a = 0, the answer is 1, not 0 Edited by author 12.10.2012 23:50 I have executed the program and when I input 0 the result is also 0. But still they are not accepted #include <stdio.h> int fact(int n, int k){ int res = 1; if (n == 0) return res; while (n > k) { res *= n; n -= k; } if (n % k) res *= (n % k); else res *= k; return res; } int main () { char sym; int n = 0; int symCount = 0; scanf("%d ", &n); while (scanf("%1[!]", &sym) == 1) { symCount++; } printf("%d\n", fact(n, symCount)); return 0; } Answer for n is n*(n+1)/2*(n+2) For example if n=2 then answer is 2*3/2*4=12 The formula is correct and is easily proven by solving the sums: sum(i=0 -> N) sum(j=0 -> N) (i + j) Edited by author 03.02.2012 17:25 Actually the inner sum needs to start at i, not at zero. Starting at 0 counts non-double dominoes twice. My program only read integer and write integer (ready formula). Why it works 0.015 sec? Edited by author 11.06.2009 00:15 Because this is the minimum measurement time possible on the current version of the judge. Let a be the number of objects. Let b be the number of objects in a group. Let A[a] is the number of permutations of a objects ( A[2] = 2, A[3] = 2*3, A[4] = 2*3*4...) So: f[a][b] is the number of groups with b objects. You have the formula: f[a][b] = f[a-1][b] * b + f[a-1][b-1]; And the result = f[n][1] * A[1] + f[n][2] * A[2] + ... + f[n][3] * A[3] A group is formed by equal objects in a relation. For example: a = b < c = d (2 groups ab and cd) a = b < c < d (3 groups ab, c and d) ... I think when N is increased to 1000, everyone will solve it by DP or maths, not cheat :-) thank you for your idea. I had learnt a lot from yours. solve it with c++ algo are: dp[i,j]=dp[i,k]&&dp[k+1,j] main code are: for(length=0;length<n;length++) { for(i=0;i+length<n;i++) { if(find(i,i+length,maintree)) { dp[i][i+length][0]=9999; dp[i][i+length][1]=1; save[i][i+length]=choose; } else { bestadd=100;bestj=-1; for(j=i+1;j<i+length;j++) if(dp[i][j][0]!=-1&&dp[j+1][i+length][0]!=-1) { if(dp[i][j][1]+dp[j+1][i+length][1]<=bestadd) { bestadd=dp[i][j][1]+dp[j+1][i+length][1]; bestj=j; } } dp[i][i+length][0]=bestj; dp[i][i+length][1]=bestadd; } } } hope it will do you a favor i try to find but i don't know where i'm wrong ?? Who know test 10, please tell me !!! Tks very much Hello, How can my program get AC even it returns wrong answer for the first test? import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter;
public class SandrosBook {
public static void main(String args[]) throws IOException{
InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); PrintWriter out=new PrintWriter(System.out);
int[] a=new int[26];
String s=br.readLine(); int i=1; int start=0,end=0; start=s.charAt(0)-97; int max=0;
while(i<s.length()){ char c=s.charAt(i); a[(int)c-97]++; i++; }
int k=0; for(int ii=0;ii<26;ii++){ if(a[ii]>max) { max=a[ii]; k=ii; } }
k=k+97;
System.out.println((char)k); out.flush(); }
} try test: b right answer "b", but you output "a" Edited by author 09.03.2012 14:09 There is my code. My stress works fine. The size of output program is something near 4/5 * length bytes. Using gets, all endl are written as '@'. There is an assert, that i haven't forgotten some symbols. Please, help! http://pastebin.com/WnQvat6gI suggest I got CE because of too long strings.) Stupid compiler:) I got AC) I have some question: why symbols '[', ']' and '~' are included in the texts? It's not clear from the statement, but I checked: output of your program (program, that prints input and has little size) may have size more than 64kb (all programs have some restrictions to the size in bytes). Apologies, since I started this thread. Understood the problem got AC. when I placed two books on shelf side by side I understood the problem. Thanks to all memebers who posted in other threads. Regards Anupam Edited by author 11.03.2012 02:41 The problem relies on the unstated assumption of how people "normally" put books on shelves, and assumes that the pages in the book are arranged like books in Western languages. Just use long arithmetics and calculate 36*pow(55,k-1); How did u get the formula What are the libraries and functions u use for long arithmetic in c++. There are no such libraries! You must write long arithmetics by yourself ;) Thank finaly something extra ordinary good. Thanks allot. I was searching for this for so long time. Thanks, thanks, thanks... This program explain how get 36 and 55. #include <iostream> using namespace std; __int64 s( __int64 x ){ __int64 ans = 0; while( x ){ ans += x % 10; x /= 10; } return ans; } int main(){ __int64 kol = 0; for( __int64 i = 0; i <= 9; ++i ){ for( __int64 j = 0; j <= 9; ++j ){ if( s(i+j) == s(i)+s(j) && i+j<=9 ){ cout << " " << i << " " << j << " s=" << s(i+j) << endl; ++kol; } } cout << "-------------------------" << endl; } cout << "kol = " << kol << endl; kol = 0; for( __int64 i = 1; i <= 9; ++i ){// последний разряд без нулей т.к. число must be без ведущих нулей for( __int64 j = 1; j <= 9; ++j ){ if( s(i+j) == s(i)+s(j) && i+j<=9 ){ cout << " " << i << " " << j << " s=" << s(i+j) << endl; ++kol; } } cout << "-------------------------" << endl; } cout << "kol = " << kol << endl; return 0; } Edited by author 23.11.2011 03:11 Edited by author 23.11.2011 03:12 Edited by author 23.11.2011 03:12 Edited by author 06.04.2009 19:06 try this 2 999 1000 -1000 the correct answer is 999 2999 Edited by author 21.12.2011 21:02 Edited by author 21.12.2011 21:02 why? Hi Panther.uz, try this 2 999 1000 -1000 the correct answer is 999 2999 This is correct answer as the exit is at 999 so in positive direction if a person walks 999 he escapes. This explains first answer. If a person walks in reverse he encounters obstruction at 1000. Thus he reverses to origin and proceeds to exit. Total 1000+1000+999=2999. Hope this helps. Regards Anupam |
|