1 条题解
-
0
C :
#include <stdio.h> #include <stdlib.h> #include <math.h> int main() { long i,n,c=0; scanf("%d",&n); for(i=2;i<=sqrt(n);i++) { if(n%i==0) { if(i==n/i) { c=c-i; } c=c+i+n/i; } } printf("%d",c); return 0; }C++ :
#include <iostream> #include <iomanip> #include <cmath> using namespace std; int main(){ int a,i,s=0; cin>>a; for(i=2;i<=a-1;i++){ if(a%i==0){ s=s+i; } }cout<<s<<endl; }Pascal :
var n,i,s:longint; begin read(n); s:=0; for i:=2 to n-1 do if n mod i=0 then s:=s+i; writeln(s) end.Java :
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n = sc.nextInt(); int b=0; for(int a =2;a<n;a++){ if(n%a==0){ b=b+a; } } System.out.println(b); } }Python :
import math; n = int(input()); s = 0 for i in range(2,int(math.sqrt(n)) + 1): if n % i == 0: if i * i == n: s = s + i; else: s = s + i + n // i; print(s)
- 1
信息
- ID
- 82
- 时间
- 1000ms
- 内存
- 64MiB
- 难度
- 9
- 标签
- 递交数
- 11
- 已通过
- 3
- 上传者