Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
Страница 7 |
I don't understand the question. Help !! | Rithik Linkon Penaru | 1083. Факториалы!!! | 13 апр 2024 17:23 | 1 |
Can Anyone be kind enough to explain this ques to me? I'll be grateful to you.. |
hint for all test case | Almas Turganbayev | 1083. Факториалы!!! | 19 янв 2023 16:22 | 1 |
be attentive with loop (while)! we know formule n - x * k =) and in depends of number parity condition will be >= (ex. [n - x * k >= n mod k] or [n - x * k >= k]). Good luck!) Edited by author 19.01.2023 16:23 |
Why "Wrong Answer" | Tanjila Hossain | 1083. Факториалы!!! | 17 июн 2022 18:45 | 1 |
what is wrong with my program? I used Python code below: n = input() list = n.split() n = int(list[0]) k = len(list[1]) if (n < k): p = k else: p = n
i=2 num = n - k if (n>=1 and n<=10) and (k>=1 and k<=20) and (num > 0): if((n%k) == 0): while(num>k): p = p*num num = n-i*k i=i+1 p = p*k else: while(num>(n%k)): p = p*num num = n-i*k i=i+1 p = p*(n%k) print(p) Edited by author 17.06.2022 20:39 |
compiler problem | khodezatuk kobra | 1083. Факториалы!!! | 27 май 2022 20:45 | 1 |
#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; } |
TLE on Test Case 2 | Jyotirmay Nag | 1083. Факториалы!!! | 21 апр 2022 10:13 | 1 |
#include<bits/stdc++.h> using namespace std; int main() { int n; int mul = 1; string s; cin>>n>>s; int k = s.size(); if(n%k==0){ int in = n; int temp = k; while(1){ mul = mul*in; in = in - k; if(in==k){ mul*=in; break; } } } else{ int in = n; while(1){ mul = mul*in; in = in - k; if(in==(n%k)){ mul*=in; break; } } } cout<<mul<<endl; return 0; } What is test case 2? |
Python 3 solution | faysalf | 1083. Факториалы!!! | 16 июл 2021 09:03 | 1 |
#I don't know why i start from lk+7. If anyone knew about that, please notify me. import sys n,k = sys.stdin.readline().split() n = int(n) lk = len(k) res = 1 for i in range(lk+7,-1,-1): t = n - i*lk if t>0: res *= t sys.stdout.write("%d\n"%res) Edited by author 16.07.2021 09:03 |
why wrong on #T5 | Bu1bu1 | 1083. Факториалы!!! | 13 мар 2021 01:25 | 1 |
#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; } |
Simple algorithm | Littel_John | 1083. Факториалы!!! | 6 ноя 2020 18:45 | 1 |
A simple way to solve is to begin with a value x which going to depend whether n % k == 0. and increase it by k until it becomes n. and of course on each step multiply it to your sum which is initially 1. |
on drugs | MARAZ MIA | 1083. Факториалы!!! | 13 окт 2020 18:41 | 1 |
for n=2,k=3 ans=2*(2-3)*(2-6)*(2-9)*..... The author must include the condition that n>=k.. |
To admin: Ошибка при чтении данных или... | SpamBot | 1083. Факториалы!!! | 21 янв 2019 11:57 | 1 |
На Паскале не работает код если начать его так: read(n); read(s); (или readln(s)) n - longint, s - string Но если так: readln(s); А затем разрезать на n и s1, то всё ОК. Разве так и должно быть? |
easy solution for python | Yucheng | 1083. Факториалы!!! | 3 ноя 2018 20:50 | 1 |
a,b=input().split() n=int(a) k=len(b) temp=n t=k while temp-k>0: n*=(temp-k) k+=t print("%d"%n) |
String takes 1 space count extra when input is !!. Please help me out | Saurav Jaiswal | 1083. Факториалы!!! | 9 июн 2018 19:53 | 1 |
import java.util.*; import java.lang.*; public class Factorial{ public static void main(String[] args){ Scanner cin=new Scanner(System.in); int n=Integer.parseInt(cin.next()); String k=cin.nextLine(); int j=k.length()-1; int sum=1; for(int i=n;i>0;i-=j){ sum=sum*i; } System.out.println(sum); } } |
What's Wrong with my answer?WA test#10..It works absolutely perfectly in my computer & all conditions are fulfilled | Scaletta_Z | 1083. Факториалы!!! | 5 апр 2018 15:43 | 1 |
using namespace std; #include<iostream> #include<string> #include<sstream> #include<ctype.h> void factorial(unsigned long n,unsigned long k); int main() { unsigned long counter=0; string s; unsigned long n; while(getline(cin,s)) { counter=0; string::size_type position,position2; position=s.find(' '); string num; for(int i=0;i<position;i++) { if(isdigit(s[i])) num+=s[i]; } stringstream ss(num); ss>>n; position2=s.find('!'); if(position2==position+1) { for(int i=position+1;i<s.size();i++) if(s[i]=='!') counter++; factorial(n,counter); } } } void factorial(unsigned long n,unsigned long k) { unsigned long res=1; int mod=n%k; unsigned long mul=n; if(mod!=0) { while(mul>1) { res*=mul; mul=mul-k; } cout<<res<<endl; } else { while(mul>=k) { res*=mul; mul=mul-k; } cout<<res<<endl; } } Edited by author 05.04.2018 15:46 Edited by author 05.04.2018 15:47 |
What's the problem? Can anyone help me plz? | Sam Dipto | 1083. Факториалы!!! | 10 мар 2018 18:57 | 1 |
#include <iostream> #include <string> using namespace std; int main() { int n,m=1; string k; cin>>n; cin>>k; int j=k.length(); for(int i=n;i>=(n%j);i-=j){ m=m*i; } cout<<m<<k; return 0; } |
Can you check out what's wrong here ? (c++) | Said707 | 1083. Факториалы!!! | 28 янв 2018 23:08 | 1 |
#include <bits/stdc++.h> using namespace std; int main(){ int n, sana,s; char k[21]; cin>>n; cin.getline(k,sizeof(k)); sana = strlen(k)-1; if (1<=n&&n<=10&&1<=sana&&sana<=20){ if(n%sana==0) { s=sana;} else { s=1;} while(n>0){ s*=n; n=n-sana;} cout << s << endl; } } Edited by author 28.01.2018 23:09 |
C# Solution | Serge | 1083. Факториалы!!! | 19 мар 2023 18:48 | 2 |
//Don't ask me. I don't know. Just work. If anybody can tell me why for (int i = k + 7; i >= 0; i--) and why we needn't n%k - Please, tell! I don't understand. using System; namespace ConsoleApp32 { class Program { static void Main(string[] args) { string[] vvod = Console.In.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); int n = int.Parse(vvod[0]); string k1 = vvod[1]; int k = k1.Length; int q = 1; for (int i = k + 7; i >= 0; i--) { int t; t = n - i * k; if (t > 0) q *= t; } Console.WriteLine(q); } } } Edited by author 13.01.2018 23:49 because we have more than 1x! (minimum 2) and less or exactly 9 (because we have 9 numbers 2...10 and it nevermind if we have more !...! than 9). so we have k = 9-2 =7 (maximum) if we use % and the number of '!' is > 10 we have wrong answer, because we have zero: x%y=0 Edited by author 19.03.2023 19:49 |
About a custom test case. | Meraj al Maksud | 1083. Факториалы!!! | 12 фев 2023 19:37 | 3 |
For n = 10 and k = 20, what should be the output? Well, obviously it's not 0! For this test case (n=10, k=20) answer is equal to 10. why? Can you please explain? |
Runtime error(access violation) | Mithun Saha | 1083. Факториалы!!! | 23 июл 2017 21:57 | 4 |
#include<stdio.h> #include<stdlib.h> #include<string.h> int main() { long int n,k,val,fact=1,coeff=0;
char ch[24],*num,*excl;
gets(ch);
num=strtok(ch," "); n=atoi(num);
excl=strtok(NULL,NULL); k=strlen(excl);
while(coeff*k<n) { val=n-coeff*k; fact=fact*val; coeff++; }
if(n%k!=0) fact=fact*(n%k); else fact=fact*k;
printf("%ld",fact);
return 0; } Hi! I am getting runtime error(access violation) although the solution seems to work for different set of inputs. Please help me out! http://ideone.com/1tNjl7I have corrected your solution. Even if fix Access violation, You are just WA#5 (Because of a logic error) Edited by author 21.07.2017 00:59 Hi Mahilewets! Thanks a lot! I did correct the "Runtime error" but was getting a "Wrong answer" error due to the error in logic in the while condition. Your's is the right one. Just a query though(pardon my ignorance as I am new to this kind of stuff). How do you find the test cases for each problem apart from the one already given? |
WRONG TEST 15!!! => БЕРИТЕ МАССИВ CHAR РАЗМЕРОМ 21 ЭЛЕМЕНТ))) | Ilya | 1083. Факториалы!!! | 12 янв 2017 00:21 | 1 |
С 20 не проходит 15 тест!!! |
WA test 10 C++ | TIU_Sarexer | 1083. Факториалы!!! | 26 окт 2016 21:47 | 1 |
#include <iostream> #include <string> using namespace std; int main() { int num, res; string c, b = "!", a = "!"; cin >> num >> c; res = num; int sign = 0; for (int i = 1; b <= c; i++) { b = b + a; sign = i; } if (num%sign != 0) { for (int i = 1; i*sign < num; i++) { res = res * (num - i*sign); } res = res *(num%sign); } else { for (int i = 1; i*sign < num; i++) { res = res * (num - i*sign); } } cout << res; return 0; } |