Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
Факапы не написанные в условии | Sinigami17 | 1083. Факториалы!!! | 16 фев 2014 02:36 | 2 |
1) множитель не может быть отрицательным 2) умножать надо не по количеству восклицательных знаков а пока i*k < n 3) если ( n - i*k ) равно n % k или ( n - i*k ) равно k значит мы посчитали факториал ( то есть надо больше ничего с числом не делать ) 4) n и k от 1 до 20 5) составители задачи тупые мудаки I would say the same ("tupoi mudak" (*)) about the author of the post. Problem statement is more than clear: "n!!…! = n(n−k)(n−2k)…(n mod k)", "X mod Y — a remainder after division of X by Y", then even example is given: "10 mod 3 = 1". If after all this you couldn't derive that "1) множитель не может быть отрицательным" - then you're really (*) "3) если ( n - i*k ) равно n % k или ( n - i*k ) равно k значит мы посчитали факториал ( то есть надо больше ничего с числом не делать )" - just copy from the problem statement "4) n и k от 1 до 20" - just wrong (n <= 10, as, again, given in the statement) |
Runtime error #1 Java | anonymous | 1083. Факториалы!!! | 12 фев 2014 04:45 | 2 |
maybe you divide a number by zero to get that runtime error |
Tricky question. Read it CAREFULLY. Expand to see the hint. | Ashwin Kumar | 1083. Факториалы!!! | 31 дек 2013 23:42 | 1 |
the product is : n*(n-k)*(n-2*k)... till---> k if divisible by k, i.e. the last non zero value of n OR n(mod)k which is again the last non zero value of n. You don't have to multiply it with k or n mod k again. |
HELP ME PLEASE! | KOTMAKRUS | 1083. Факториалы!!! | 13 ноя 2013 16:51 | 1 |
I have 1 test runs but on the server WA test 1!!??? program pro; var n,k,t:byte; s:string; sum:integer; BEGIN read(n,s); t:=1; k:=length(s)-1; if n mod k=0 then begin sum:=n; while n-t*k>0 do begin sum:=sum*(n-t*k); t:=t+1; if sum*(n-t*k)<0 then break; end; sum:=sum*k; end else begin sum:=n; while n-t*k>0 do begin sum:=sum*(n-t*k); t:=t+1; if sum*(n-t*k)<0 then break; end; sum:=sum*(n mod k); end; write(sum); END. 9 !! My program write 945 and why WA 1?????? |
Каким должен быть факториал, если данные не валидны? | ranetka_st | 1083. Факториалы!!! | 2 ноя 2013 20:33 | 3 |
Каким должен быть ответ ,если значения n или k не валидны? Например, если не указать k. Или ввести значения, не попадающие в диапазон? RTFM: http://acm.timus.ru/help.aspx?topic=judge "Input data in the test cases always satisfy the constraints described in the problem statement. You don’t need to verify these constraints in your solutions." |
Integer vs Long integer | Marius Zilenas | 1083. Факториалы!!! | 13 окт 2013 19:13 | 1 |
I think description of the problem should state that "long numbers have to be used". So for this problem use long integers. |
Integer vs Long integer | Marius Zilenas | 1083. Факториалы!!! | 13 окт 2013 19:13 | 1 |
I think description of the problem should state that "long numbers have to be used". So for this problem use long integers. |
Как на самом деле должна звучать задача! | gwire | 1083. Факториалы!!! | 16 авг 2013 19:08 | 2 |
Определение: n!!…! = n(n−k)(n−2k), где k - количество знаков "!". При расчете на любом этапе не должно получатся отрицательного числа. И все. Я только с таким условием получил "Accepted". Спасибо. Условие было действительно странное и непонятное, а, как показала практика, так ещё и неправильное. |
qayerida xato gde awipka...? | Nargiza Asqarova | 1083. Факториалы!!! | 19 июл 2013 01:41 | 7 |
var f,i:longint; k:1..20; n:1..10; s:string; begin readln(n); read(s); f:=1; k:=length(s); for i:=0 to (n div k)-1 do begin f:=f*(n-i*k); end; writeln(f); end. Nargiza sizning xatoyingiz sonni va faktarialni ajratib olishda, va bundan tashqari hisoblash tsiklida n dan 1 ga tomon qadam k shaklida oling hisoblash tsiklida n dan 1 ga tomon qadam k shaklida olinishi kerak sizda menimcha kiritish jarayonida raqam(n) va undov(!) orasida probel(_) qo'ymasdan yozganda xato ishlashi mumkin. shunda undovlarni ham raqam sifatida o'qib s ni uzunligi 0 ga teng bo'lib qoladi. shuning uchun n/l(n bo'lingan s ning uzunligi) n/0 bo'lib qolyapti shunda sizga Crash (integer division by zero) ashibka beryapti #include <iostream> using namespace std; int main() { int n,t,s; cin>>n; char k[20]; gets(k); s=n; t=n%(strlen(k)-1); if(t!=0) while(n>t) { n=n-(strlen(k)-1); s*=n; } else while(n>(strlen(k)-1)) { n=n-(strlen(k)-1); s*=n; } cout<<s<<endl;
return 0; } |
What should I do?Who can save the poor guy? | kaa..........ai | 1083. Факториалы!!! | 15 июн 2013 12:58 | 3 |
Here's my code,and I don't know what's wrong with it? #include<iostream> using namespace std; char s[25]; int main() { __int64 n,k; while(scanf("%I64d%s",&n,s)!=-1) { k=strlen(s); if(n<=k) { printf("%I64d\n",n); } else { __int64 sum=1,i; if(n%k==0) { for(i=n;i>=k;i-=k) sum*=i; } else { for(i=n;i>=n%k;i--) sum*=i; } printf("%I64d\n",sum); } } return 0; } Edited by author 15.06.2013 12:54 Edited by author 15.06.2013 12:56 |
WA Help please | Alexandr Zhelanov | 1083. Факториалы!!! | 12 дек 2012 21:39 | 1 |
var n,i,j,ans:Integer; k:integer; kvoskl:string; begin ans:=1; j:=1; read(n,kvoskl); k:=length(kvoskl); i:=n; if n mod k = 0 then begin while i>=k do begin ans:=ans*i; i:=n-j*k; inc(j); end; end else begin while i>=n mod k do begin ans:=ans*i; i:=n-j*k; inc(j); end; end; writeln(ans); end. what`s wrong? |
Неверный ответ на первом тесте... | RelaXes | 1083. Факториалы!!! | 16 ноя 2012 11:44 | 3 |
9 !! - ввод 945 - вывод пишет wrong answer var n,i:integer; res:longint; k:string; begin read(n,k); i:=0; res:=1; if n mod length(k)=0 then repeat res:=res*(n-i); inc(i,length(k)); until n-i=length(k) else repeat res:=res*(n-i); inc(i,length(k)); until n-i=1; writeln(res); end. mne toje takoy: --------------------- var x,s:string; s1,j,i,c,l:longint; begin read(x); repeat i:=i+1; s:=s+x[i]; until x[i]=' '; l:=length(x)-i; val(s,s1,c); j:=s1; repeat j:=j-l; s1:=s1*j; until j<=1; write(s1); end. |
Compilation Error | GuGo1991 | 1083. Факториалы!!! | 13 ноя 2012 13:27 | 3 |
It works but here i get Compilation Error #include <iostream> using namespace std; int main(){ int num, val, numMod; string nFuc; cin >> num >> nFuc;
int i = nFuc.length();
int mod = num % i; if(mod != 0){ numMod = num; val = numMod; while(numMod != mod){ numMod -= i; val *= numMod; } }
else if(mod == 0){ numMod = num; val = numMod; while(numMod > i){ numMod -= i; val *= numMod; } }
cout << val << endl; } |
What's Wrong ! ACM Timus system wrote me WA № Test 1 . Can anybody help me? | Александр | 1083. Факториалы!!! | 16 окт 2012 15:33 | 1 |
#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; } |
Time limit exeeded error | Darwesh | 1083. Факториалы!!! | 10 сен 2012 19:44 | 1 |
I don't know why this error occurs, even the execution time is less then the time limit???? Please help me out?
|
wa #15 | Ahmet Terzi(Ottoman)Devlet-i Âli Osman | 1083. Факториалы!!! | 31 авг 2012 15:03 | 2 |
wa #15 Ahmet Terzi(Ottoman)Devlet-i Âli Osman 31 авг 2012 13:20 what's wrong? #include <stdio.h> #include <conio.h> main() { int a,len=0,t=1; char b[20]; scanf("%d%s",&a,b); len = strlen(b); for( ; a > 1 ; a -= len ) t *= a; printf("%d",t); return 0; }
int result = 1; for (int i = n; i > 0; i -= k) result *= i; printf("%d\n", result); |
please help if accepted | amirani | 1083. Факториалы!!! | 31 авг 2012 08:03 | 2 |
please anyone help me if accepted . it gives me wrong answer on test 1 and as i suppose in test 1 k=0 and i don't know what write :) thanks... int result = 1;
for (int i = n; i > 0; i -= k) result *= i; |
what is test number 11 | Akshay | 1083. Факториалы!!! | 22 авг 2012 23:38 | 1 |
|
what is test no 2 | Muhammad Ayub khan | 1083. Факториалы!!! | 19 авг 2012 21:43 | 1 |
plz explain what this test no shows ? |
WA #5-Java | d_shuren | 1083. Факториалы!!! | 6 авг 2012 17:02 | 1 |
Edited by author 06.08.2012 17:08 |