Общий форум#include<bits/stdc++.h> using namespace std; int solve(int n, string k){ int ans=k.size(); if(n>=1){ return n*solve(n-ans); } else{ return 1; } } int main() { int t,n; string k; cin>>n; cin>>k; int result=solve(n,k); cout<<result<<endl; return 0; } This is Test 4 11 1 2 2 1 1 1 2 2 1 2 1 11 1 1 3 1 4 1 2 8 1 10 11 1 1 3 1 2 3 1 3 7 2 4 6 2 5 9 2 11 11 2 10 11 2 Answer is 01111010101 Edited by author 08.02.2013 04:06 Please, tell me how to solve this problem... Not solution but an idea or a hint... Thanks. You just have to understand the optimal algorithm for finding a shortest way from A to B on this object. I'm trying... Should I write a Function(n) wich returns the number of row in wich n shands? There is three kinds of "rows", so, what shall I do? Give me the way to think... Find optimal path from 1 to some small numbers. It will help you. Try to change direction in the optimal path as few times as possible. It must be formula, isn't it? Or there is an algo to find answer? There is a formula, but it's a bit easier to solve using algo. Convert input numbers into row/column. Row will not exceed ~33000, so you can iterate over row using algo and use math over column. Sorry, could you tell me the algorithm, otherwise I don’t understand it ... please give me some tests. Those who are getting WA4 when using C#, please use the following format to print out the output. The type of variable sum is double and individual numbers read in the second line are also converted to double first before adding them together. Console.WriteLine("{0:F6}", sum / cases); Hello women and men! I haven't been able to solve this problem for a long time. Please, help me that. Does anyone see what goes wrong with my program for the input of test #9? or test inputs maybe? EDIT: Test Case found! Edited by author 01.06.2012 22:08 Can you tell me how to fix WA 9, plz 0 30 -25.9807621135 -15 25.9807621135 -15 3.711537444785714 10.714285714285715 -11.134612334357143 -2.142857142857144 7.423074889571431 -8.571428571428571 18.557687223928568 23.57142857142857 -29.69229955828571 4.285714285714285 11.134612334357145 -27.857142857142854 As the matter of fact this problem can have multiple solutions: This one is also correct solution for the first sample test case -14.998661880355732 -4.018465371022687 4.019237844660736 14.998454896701402 10.979424035716015 -10.979989525657688 -29.99999996018567 0.00154508598054 15.001338063819592 25.979989536091384 14.99866189635838 -25.981534622043206 deleted Edited by moderator 23.07.2022 20:36 Почему в случае 1 10 ответ 9 если 0 тоже число в котором не идут два подряд ноля? Просто 2 раза получил ВА, поменял на 9 и АС. N ≥ 2. Test "1 10" is incorrect; there is no such test in the test set. You are wrong. In case 1 10 you have exactly nine 1-digit numbers without two or more subsequent zeros. They are: 1,2,3,4,5,6,7,8 and 9. What do you mean? '0' is *also* a 1-digit number without two or more subsequent zeroes, no? Also, yay for necroposting! Calculate matrix with modulo 10^9 + 7 #include <bits/stdc++.h> using namespace std;
int const N = 123456; #define pi acos(-1.0) typedef long long ll;
int ar[N],xar[N],uses[N];
struct points { double x, y; int id; points() {} points(double x, double y) : x(x), y(y) {} } ;
double ang(const points &p){ double res = atan2(p.y, p.x); if(res < 0) res += 2.0 * pi; return res; }
struct cmp{ inline bool operator () (const points &p1, const points &p2){ double ang1 = ang(p1)*(180/pi), ang2 = ang(p2)*(180/pi); if(fabs(ang1 - ang2) < 1e-9){ ll d1 = (ll)p1.x * (ll)p1.x + (ll)p1.y * (ll)p1.y; ll d2 = (ll)p2.x * (ll)p2.x + (ll)p2.y * (ll)p2.y;
return d1 < d2; } return ang1 < ang2; } };
points pt[N];
int main() { int n; cin >> n; for(int i = 0; i < n; i++){ cin >> pt[i].x >> pt[i].y; pt[i].id = i+1; } sort(pt, pt+n, cmp()); cout<<pt[0].id<<" "<<pt[(n/2)].id<<endl;
return 0; } I know this is an old post. but for others' reference, we should use long long to avoid integer overflow. Sort the intervals by length. and from i=0 to no_of_intervals, mark the query numbers. Make sure that each query number is marked by only one interval. Edited by author 17.05.2022 11:32 What's the test for WA#9? Try 3 0 0 10 10 10 0 20 10 20 0 30 10 Answer 36 try a rectangle in the negative area Windows, linux, maxOS? Why I can't include <windows.h>? (Compilation error: No such file or directory) 3 4 1 100 1000 0 1 1 1000 0 100 0 1000 100 //answer 1 1 2 2 1 1 1000000000 //answer 1 5 6 525 0 171 0 872 673 0 843 0 0 0 0 0 277 0 202 0 0 0 0 733 957 65 96 637 566 0 0 0 441 //answer: 4 4 5 5 5 5 10 1 10 10 10 1 1 10 10 10 1 10 1 1 1 1 1 1 10 1 10 10 10 10 1 //answer: 2 2 1 1 1 1 1 10 100 90 80 70 60 50 40 30 20 10 //answer: 10 5 6 1 0 1 1 1 1 1 0 0 1 1 1 1 1 0 1 1 1 1 0 0 1 1 1 1 0 1 1 1 1 //answer: 2 2 3 3 3 2 2 3 2 3 1 1 1 1 3 //answer: 2 2 1 1 3 1 1 1 1 //answer: 1 1 1 You 3rd and 6th test cases are wrong. The fee should be positive. тест 1: n=9 k=2 тест 2: n=1 k=1 тест 3: n=10 k=1 тест 4: n=8 k=1 тест 5: n=10 k=2 тест 6: n=7 k=2 тест 7: n=1 k=2 тест 8: n=2 тест 9: n=10 k=5 тест 10: n=9 k=5 n=3,4,5,6 не встречается... тест 8 - к по условию не может быть меньше 1. В единственной строке сначала дано целое число n, 1 ≤ n ≤ 10, затем ровно один пробел, затем k восклицательных знаков, 1 ≤ k ≤ 20. про значение К в этом тесте не известно а какой ответ на 9 тест? 1) 50 Очень интересно а как вы эти тесты извлекли? Edited by author 10.02.2010 23:53 Какой ответ на тест 5? 945? Тест 8 - просто супер. Явная неучтенка. И сколько еще таких тестов? Просто офигенная постановка задачи. Edited by author 16.04.2011 19:50 Скажите,пожалуйста, какой должен быть ответ в тесте номер 8? Я уже пробовала,чтобы программа не пропускала такие варианты с помощью repeat, пробовала ставить в таком случае ответ 1, ответ 0, ответ - само число. Ничего не получается! Edited by author 29.07.2014 13:12 Тест 10: 9 !!!!! = 9(9-5)(9 mod 5) = 9*4*4 = 144 Почему вылазит неправильный ответ?! N mod K — это последний больший нуля элемент ряда N - XK. В данном случае этот элемент первый и он же последний, не нужно умножать на него два раза. Иными словами, мы вычитаем K от исходного числа, и умножаем на получившееся, и повторяем так до тех пор, пока получившееся число не станет нулём или меньше. Еще вопрос: 2 !!! = ? 2 или 4? и какие вводные 11-го теста? Меня очень интересует как в примере 9 !! получилось равным 945 если разбирать описание задачи то получим: n = 9 k = 2 n mod k = 1(есть остатое от деления) тогда получаем 9!! = 9*(9-2)*1 = n(n-k)(n mod k) = 9*7*1 = 63 Ну откуда 945 невкурю???? This problem is easily solving without any precalcing or info about tests. Not more than 15-20 lines of code. I did not ask about the problem of solving the problem. I asked about the correctness of my reasoning, I can not right in the calculation of 9 !! 9 !! i 1) n:=9*(9-2) 2)n:=63*(9-4) 3)n:=315*(9-6) 4)n:=945*(9-8) This is correctness of your reasoning. In my program test 5 is correct, but system writed, that wrong. Answer - 7680 In my program test 5 is correct, but system writed, that wrong. Answer - 7680 All manual tests ok. Test 5 is also in error. I do not understand this... import java.util.*; public class Factor { public static void main(String[] args){ Scanner put=new Scanner(System.in); int n,k,fac; String ffc; n=put.nextInt(); ffc=put.next(); k=ffc.length(); fac=n; for(int i=1;i<(n/k);i++){ fac=fac*(n-(i*k)); } if(n%k!=0)fac=fac*(n%k); else fac=fac*k; System.out.print(fac); } } Edited by author 29.10.2012 17:37используя гамма функцию можно в одну строчку :) Застрял в тесте 8: #include<stdio.h> #include<string.h> int main(){ int n, i, l; char k[20]; scanf("%d%s", &n, k); l = strlen(k); int result = n; i = n - l; do{ result = result * i; i = i - l; } while (i > n % l); if (n == 1) result = 1; printf("%d", result); return 0; } Edited by author 02.12.2017 02:41 Edited by author 02.12.2017 02:41 Edited by author 25.07.2014 12:47 9 !! = 9*(9-2)*(9-2*2)*(9-2*2*2)....*1=9*7*5*3*1=945 Answers for numbers from topic: 1. 945 2. 1 3. 3628800 4. 40320 5. 3840 6. 105 7. 1 8. 2 (if in this case k = 1) 9. 50 10. 36 Моё нестандартное решение :) import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class proga { public static void main(String[] args) throws IOException { BufferedReader sc = new BufferedReader(new InputStreamReader(System.in)); String[] temp = sc.readLine().split(" "); int ch = Integer.parseInt(temp[0]); int len = temp[1].length(); int ost = ch%len; int result = ch; if(ost==0){ost+=len;} while(ch!=ost) { ch-=len; result*=ch; } System.out.println(result); } } а какой ответ на тест 5 ? what's the right answer for test 5 ? who knows ? can you give a hand pls тест 1: n=9 k=2 тест 2: n=1 k=1 тест 3: n=10 k=1 тест 4: n=8 k=1 тест 5: n=10 k=2 тест 6: n=7 k=2 тест 7: n=1 k=2 тест 8: n=2 тест 9: n=10 k=5 тест 10: n=9 k=5 n=3,4,5,6 не встречается... why wrong on test 5?? #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; } 8th test is 2 !! and the answer is 2 clarification if you are stuck. RedBlue Mana can be made from red or blue i.e C can use (remA + remB) after using A and B through X and Y respectively. Do count what you use from C when required. |
|