1 条题解
-
0
C++ :
#include <bits/stdc++.h> using namespace std; int main(){ int n,i,j; cin>>n; for(i = 1;i <= n;i++){ cout<<i<<":"; for(j = 1;j <= n;j++){ if(i % j == 0){ cout<<j<<" "; } } cout<<endl; } }
Java :
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); for(int i=1;i<=n;i++) { yinzi(i); System.out.println(); } sc.close(); } public static void yinzi(int n) { System.out.print(n+":"); for(int i=1;i<=n;i++) { if(n%i==0) { System.out.print(i+" "); } } } }
Python :
n = int(input()) for i in range(1, n + 1): print('%d' % i, end=':') for j in range(1, n + 1): if i % j == 0: print('%d ' % j, end='') print()
- 1
信息
- ID
- 2439
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者