Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
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 |
[JAVA] Why is it CRASH ? :( | icytwister | 1083. Факториалы!!! | 7 июн 2012 13:04 | 2 |
import java.util.*; public class MyFact { int factorial(int n,int k) { int res; if(n==1) return 1; else if((n-1)%k!=0) return 1;
res=factorial(n-k,k)*n; return res;
}
public static void main(String [] args) { int fact=1;
MyFact f=new MyFact();
Scanner in=new Scanner(System.in); int n=in.nextInt();
int k=in.nextInt(); System.out.print(+f.factorial(n,k)); } } Edited by author 05.06.2012 18:20 Read the input data format carefully! An integer number "k" does not follow after integer number n. Input format example: 9 !! You should count number of exclamation marks (!). |
why compilation error ? I wrote in C# | Jojas | 1083. Факториалы!!! | 2 май 2012 22:11 | 2 |
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 |
Test 11 | nbodea | 1083. Факториалы!!! | 7 апр 2012 14:06 | 1 |
I don't know what's wrong, but it seems that i get wrong answer on test 11. Do you have any idea what it contains? |