📄 toj_2901_gen.cpp
字号:
/*2901. Very easy --------------------------------------------------------------------------------Time Limit: 2.0 Seconds Memory Limit: 65536KTotal Runs: 131 Accepted Runs: 46Case Time Limit: 1.0 Seconds--------------------------------------------------------------------------------This is very simple problem, you only have to display the prime factorization of nCr. For example: 10C5=252=2 * 2 * 3 * 3 * 7Input:This is multiple test case problem. Input is terminated by end of file.Each line contains one test case and it contains two positive numbers n and r.(2 ≤ n ≤ 3000 && 1 ≤ r ≤ n-1)Output: Out put is the prime factorization of nCr. The output format is below:nCr = n1 * n2 * n3 * .......... * nthSample Input:10 520 108 430 25Sample Output:10C5 = 2 * 2 * 3 * 3 * 720C10 = 2 * 2 * 11 * 13 * 17 * 198C4 = 2 * 5 * 730C25 = 2 * 3 * 3 * 3 * 7 * 13 * 29Problem Setter: MD. SHAKIL AHMED. (CUET AGRODUT)Source: New Year Challenge Contest*/#include<cstdio>#include<cstring>#define MAX 3010FILE *fOut = fopen( "toj_2901_prime.txt" , "w" );void setPrime( int num[] ){ int i , j; memset( num , 0 , MAX * sizeof( int ) ); for ( i = 2; i < MAX; i++ ) { if ( num[ i ] == 0 ) { for ( j = i * 2; j < MAX; j+= i ) num[ j ] = -1; } }} int main(){ int i , j; int num[ MAX ]; setPrime( num ); num[ 0 ] = 1; num[ 1 ] = 1; fprintf( fOut , "{1" ); for ( i = 1;i < MAX; i++ ) { if ( num[ i ] == 0 ) fprintf( fOut , ",%d" , num[ i ] ); else fprintf( fOut, ",SL" ); } fprintf( fOut , "}" ); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -