toj_2918_1.cpp
来自「Tianjin University Online Judge 的80多道题目 」· C++ 代码 · 共 48 行
CPP
48 行
/*2918. LCM Revisited Time Limit: 5.0 Seconds Memory Limit: 65536KTotal Runs: 2 Accepted Runs: 2Case Time Limit: 1.0 SecondsAll of you know about LCM (Least Common Multiple). For example LCM of 4 and 6 is 12. We need to find the number of such m that 1 ≤ m ≤ n, for every m LCM (m, n)> n and LCM (m, n) < m*n.For example if n=6, then for every m (1≤m≤6) LCM (1, 6) = 6, LCM (2, 6) =6, LCM (3, 6) = 6, LCM (4, 6) = 12, LCM (5, 6) = 30, LCM (6, 6) = 6. So here only one number 4 have a LCM (4, 6) = 12 in the range 6< LCM (4, 6) <24. So the answer will be 1.InputEach line contains one nonzero positive integer n (0 < n < 231). Last line will contain zero indicating the end of input. This line should not be processed. You will need to process maximum 1000 lines of input.OutputFor each line of input, print the number of m.Sample Input165120Sample Output0103Problem Setter: Kreshano DuttaSource: CUET individual contest*/#include<cstdio>int main(){ int n , i , p[ 1000000 ][ 2 ] , nOfP; while ( scanf( "%d" , &n ) != EOF && n != 0 ) { nOfP = 0; while ( n != 0 ) { for ( i = 1; i < n; i++ ) { if ( prime[
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?