Common Board#include <stdio.h> #include<math.h> void main() { float a[1024]; int i=0,count=0; while(scanf_s("%f",&a[i])) { printf("if you want to end press a char\n"); if ((a[i]>0||a[i]==0)&&(a[i]==pow(float(10),18)||a[i]<pow(float(10),18))) {
a[i]=sqrt((float)a[i]); count++; i++; } else break; } getchar();
for (int i=count-1;i>0||i==0;i--) printf("%.4f\n",a[i]);
} If you enumerate vertices from 0, be sure that you decrease root's number before calling DFS. I don't understand what problem is it #include <stdio.h> #include <math.h> int main() { long double i[10000] = {0}; int c,tmp,j=0; while ((c = getchar()) != EOF) { if ( (c != ' ') && ( c != '\n' ) && ( c != '\t' ) && ( c != '\0' ) ) { i[j] = i[j]*10 + ((int)c - 48) ; } if ( ( tmp!=' ' && tmp!='\n' && tmp!='\t' && tmp!='\0' ) && ( c == '\0' || c==' ' || c=='\n' || c=='\t' ) ) j++; tmp = c; } for ( j-- ; j>=0 ; j--) { printf("%Lf\n", sqrtl(i[j])); } return 0; } What is about the test 3 ? first:temp used without being initialized second:when do the while end up if I just put in 3 numbers #include <stdio.h> #include<math.h> void main() { float a[1024]; int i=0,count=0;
while(scanf("%f",&a[i])) {
a[i]=sqrt((float)a[i]);
count++; i++; }
for (int i=count-1;i>0|i==0;i--)
printf("\n%.4lf",a[i]); } Can number of decks for already placed ships be more than 4? In another words, is this test possible: 30000 30000 1 1 1 30000 H 1 ? No. Read "Site news". Thank you! But there is one more problem: about what is N and what is M. Many people (and me) had WA #22, and when they flip n and m in their input they got AC. It happens because statement is not very clear: it's said N and M are "vertical/horizontal size of the playing field". This way of describing field size is not very common and makes some misunderstandings. Can't you change it to just "height/width of the playing field" or "number of horizontals/verticals of the playing field" ? Edited by author 24.08.2009 17:36 да, вполне на мой взгляд нечто похожее в тесте №6 can be. by my mind, the 6th test is like More a puzzle than a programming challenge.... Give me more examples to test, pls. import java.util.Scanner; import java.util.Scanner; public class DoubleHappiness1432 { private static String number; private static int[] ticket; private static int[] ticket2; private static boolean flug = true; private static int sum1 = 0; private static int sum2 = 0; private static boolean pr = false; private static int sum12 = 0; private static int sum22 = 0; public static void main(String[] args) { Scanner scanner = new Scanner(System.in); number = scanner.nextLine(); if(number.length()%2==0 && number.length()>=4 && number.length()<=1500){ toInt(); stop:while (flug) { flug=false; start:for (int j = number.length()-1; j >= 0; j--) { if (ticket[j] < 9) { ticket[j]+=1; if(summary() || summary1()){ pr = true; break stop; }else toNull(j); flug=true; break start; } } } if(!pr) System.out.print("No solution"); } } private static void toInt(){ ticket = new int[number.length()]; ticket2 = new int[number.length()]; for (int i = 0; i < number.length(); i++) { ticket[i] = Character.digit(number.charAt(i), 10); } } private static void toNull(int i){ for (int j = i+1; j < number.length(); j++) { ticket[j]=0; } } private static boolean summary(){ for (int i = 0; i < number.length()/2; i++) { sum1 += ticket[i]; } for (int i = number.length()/2; i < number.length(); i++) { sum2 += ticket[i]; } if (sum1==sum2) { System.arraycopy(ticket, 0, ticket2, 0, ticket.length); for (int i = number.length()-1; i >=0; i--) { if (ticket[i] < 9) { ticket[i]+=1; flug=true; toNull(i); break; } } if (flug) { for (int i = 1; i < ticket.length; i+=2) { sum12 +=ticket[i]; sum22 +=ticket[i-1]; } }else{return false;} if(sum12==sum22){ for (int i = 0; i < number.length(); i++) { System.out.print(ticket2[i]); } System.out.print(" "); for (int i = 0; i < number.length(); i++) { System.out.print(ticket[i]); } return true; }else{sum12=0;sum22=0;return false;} }else{sum1=0;sum2=0;return false;} }
private static boolean summary1(){ for (int i = 1; i < ticket.length; i+=2) { sum12 +=ticket[i]; sum22 +=ticket[i-1]; } if(sum12==sum22){ System.arraycopy(ticket, 0, ticket2, 0, ticket.length); for (int i = number.length()-1; i >=0; i--) { if (ticket[i] < 9) { ticket[i]+=1; flug=true; toNull(i); break; } } if (flug) { for (int i = 0; i < number.length()/2; i++) { sum1 += ticket[i]; } for (int i = number.length()/2; i < number.length(); i++) { sum2 += ticket[i]; } if (sum1==sum2) { for (int i = 0; i < number.length(); i++) { System.out.print(ticket2[i]); } System.out.print(" "); for (int i = 0; i < number.length(); i++) { System.out.print(ticket[i]); } return true; }else{return false;} }else{sum1=0;sum2=0;return false;} }else{sum12=0;sum22=0;return false;} } } Edited by author 06.07.2011 03:58 Try this test: 316496 My program returns: 317559 317560 and yours: 318659 318660 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Factorize { class Program { static int capture(string a) { return( a.Length - 3); } static int calculate(string a) { int i,n = 0,sum=1,x=0,y=0,count=0; if (a[1] != '0') a = '0' + a; n = capture(a);
if (a[0] == '1') x = 10; else x = a[1] - '0'; count = x; sum = x; for (i = 0; i > -1; i++) { if ((count-n) <= 1) break; else { sum= sum * (x - n); count = count- n; x = count; } } return sum; } static void Main(string[] args) { string a; int sum = 0; a = Console.ReadLine(); sum = calculate(a); Console.WriteLine(sum);
} } } I copy source code then it told me compilation error? Edited by author 07.04.2008 14:47 i think it should contain Main method ..... and just your class + usings are needed not your all whole nameSpace and i think you find that out by now . Edited by author 02.05.2012 22:13 What's wrong with test 3? My programm passes everything, that has ever been suggested on this forum. Could you give another test for me? Can WA mean that text is bigger than 10000 symbols, as I declare(because I have Compillation error in case of t[100000] for some reason)? Sorry for my bad english. #include<stdio.h> int arr[11]; int num = 1; int prime[10000]; int ans = 1; int main() { for( int j = 0 ; j< 10 ; j++ ) { scanf("%d",&arr[j]); if( arr[j] == 1 ) { continue; } for( int i = 2 ; i <= arr[j] ; i++ ) { while( arr[j] % i == 0 ) { prime[i]++; arr[j] = arr[j] /i; if( arr[j] == 1 ) { break; } } } }
for( int i = 2 ; i < 10001 ; i++ ) { ans *= (prime[i]+1) % 10 ; } ans = ans % 10; printf("%d\n",ans); //scanf("%d",&prime[0]); return 0; } My idea of the problem was the following: 1) I know, how many K-ships can be placed on the FREE board. It's a rather simple formula 2) After that I check each placed ship. For him I found all the K ships that cannot be placed on the board thanks to this ship and add them to the special array (if they aren't there already). After that I subtract the number of elements in the array out of FREE board amount and that's the answer. Who can give me test 4? I didn't think about the case K=1. But now I fixed it and have WA 11. What's that test about? Maybe you don't check when n<k or m<k (than common formula return incorrect value) excuse me, can give me test 4? Test : abcdefgh Answer : dbacfeg Is this answer correct? нет! как минимум, в первом слове букв больше :D Edited by author 01.05.2012 15:15 Edited by author 01.05.2012 15:15 Oh, of course :D I want to say, is answer dbacfegh is correct. But now I already know, that my old algorithm hadn't been correct and here is just recursion. it gives good output for every test i came up with... i dont know where is the mistake and code is very simple help pls #include <iostream> using namespace std; int main(){
int n,i; int* tab; int tabL[11]={0}; cin >> n; tab = new int [n]; for(i=0;i<n;i++){ cin >> tab[i]; tabL[tab[i]]++; } for(i=0;i<11;i++){ if(tabL[i]!=0){ cout << tabL[i] << " " << i << " "; } } getchar();getchar(); return 0; } пробовал разные способы вычисления, упираюсь в 33 тест. Какие есть мысли? try more ways reading longs How i can read all numbers in JAVA? не могу подобрать тест определяющий ошибку.... 10 1 4 3 Thank you for your prompt response)))) #include <stdio.h> int main(){ int code1; int code2; scanf("%d\n%d", &code1, &code2); if(code1 == 0001 || code2 == 0000 || code1 == code2) printf("no"); else printf("yes"); } I did not understand the task and made program for first test. Why i have WA in test 14? Edited by author 29.04.2012 17:06 If you have WA 10, check your solution on this test: 0 0 0 0 1000 0 2 59:59 00:06 Right answer is: Basic: 0 Combined: 60000 Unlimited: 0 Edited by author 29.04.2012 16:14 |
|