Ước số của n

View as PDF



Authors:
Problem types
Points: 100 Time limit: 1.0s Memory limit: 640M Input: stdin Output: stdout

Viết chương trình nhập vào số nguyên \(n\) (\(n\leq 10^7\)). In ra tất cả các ước số của \(n\). (Ước số của \(n\) là các số nguyên mà \(n\) chia hết)

Ví dụ: \(n=10\) thì in ra các số: \(1\) \(2\) \(5\) \(10\)

Input

  • Một số nguyên dương \(n\).

Output

  • In ra các ước số của \(n\).

Example

Test 2

Input
10
Output
1 2 5 10

Test 2

Input
36
Output
1 2 3 4 6 9 12 18 36

Comments

  • yeuaidoltrandinhgiahuydeptrai 5:27 p.m. 26 feb, 2025

    n=int(input())
    d=[]
    for i in range(1,int(n0.5)+1):
    if n%i==0 and i!=n//i:
    d.append(i)
    d.append(n//i)
    if int(n
    0.5)int(n0.5)==n: d.append(int(n*0.5))
    d=sorted(d)
    for i in d: print(i, end=' ')

    • phamhonganh9akhanhloi 11:05 p.m. 6 dec, 2024

      include <bits/stdc++.h>

      using namespace std;
      long long n,a[100005],x,y,z;
      bool cp(int n){return sqrt(n)sqrt(n)==n;}
      long long uoc(int n){
      if(n==1)return 1;
      int t=0;
      for(int i=2;i
      i<=n;i++)
      {
      if(n%i==0)
      {
      t++;
      if(i*i!=n)
      {
      t++;
      }
      }
      }
      }
      int main()
      {
      ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
      cin>>n;
      for(int i=1;i<=n;i++)
      {
      if(n%i==0)cout<<i<<' ';
      }
      return 0;
      }

      • vietnammuonnam_mvn 6:40 p.m. 12 oct, 2024

        import math
        n=int(input())
        a=[]
        for i in range(1,int(math.sqrt(n))+1):
        if n%i==0:
        if(ii==n):
        a.append(i)
        else:
        a.append(i)
        a.append(n//i)
        a=sorted(a)
        print(
        a)

        • Khanh_2004 11:03 p.m. 30 sep, 2024 edit 5
          #include <bits/stdc++.h>
          using namespace std;
          #define ll long long
          
          int main() {
              ios_base::sync_with_stdio(0);
              cin.tie(0);cout.tie(0);
              int n; cin >> n;
              for (int i = 1; i <= n; ++i) {
                  if (n % i == 0) {
                      cout << i << ' ';
                  }
              }
              return 0;
          }
          
          • Nguyen_Anh_Minh1 9:36 a.m. 18 jul, 2024

            n=int(input())
            for i in range(1,n//2+1):
            if n%i==0:
            print(i,end=' ')
            print(n)

            • giathinhd061 8:11 a.m. 17 jul, 2024

              import math
              n=int(input())
              dem=0
              for i in range (1,int(sqrt(n))+1):
              if (n%i==0):
              dem+=1
              if (i!=n/i):
              dem+=1
              print(dem)

              • haitrannguyenphong 9:46 a.m. 29 jun, 2024

                n=int(input())
                for i in range(1,n//2+1):
                if n%1==0:
                print(i,end=' ')
                print(n)
                code python 3 này sai ở chỗ đâu vậy mọi người?

                • kay 9:16 p.m. 25 mar, 2024

                  code python:
                  n = int(input())
                  for i in range(1,n+1):
                  if n%i==0:
                  print(i)

                  • dxuloc 11:15 a.m. 6 feb, 2024

                    test cuối lỗi à

                    • khoinguyentl2023 9:50 a.m. 11 apr, 2023

                      tang thoi gian cho python di a

                      • 2 more comments