QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#742240#9619. 乘积,欧拉函数,求和lywywTL 0ms1584kbC++14729b2024-11-13 16:09:252024-11-13 16:09:26

Judging History

你现在查看的是最新测评结果

  • [2024-11-13 16:09:26]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:1584kb
  • [2024-11-13 16:09:25]
  • 提交

answer

#include <stdio.h>
#define MOD 998244353
long long oula(int n) {
    int a,b,r,ans=0;
    int i;
	for(i=1;i<=n;i++){
		a=n;
		b=i;
		while(b!=0){
			r=a%b;
			a=b;
			b=r;
		}
		if(a==1)  ans++; 
	}
    return ans;
}
int a[2010];
int n;
long long result = 0;
void dfs(int step, int sum) {
    if (step == n) {
        if (sum == 1) {
            result = (result + 1) ;
        } else {
            result = (result + oula(sum)) ;
        }
        return;
    }
    dfs(step + 1, sum);
    dfs(step + 1, sum * a[step]);
}
int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    dfs(0, 1);
    printf("%lld\n", result%MOD);
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 1584kb

input:

5
1 6 8 6 2

output:

892

result:

ok single line: '892'

Test #2:

score: 0
Accepted
time: 0ms
memory: 1540kb

input:

5
3 8 3 7 8

output:

3157

result:

ok single line: '3157'

Test #3:

score: -100
Time Limit Exceeded

input:

2000
79 1 1 1 1 1 1 2803 1 1 1 1 1 1 1609 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2137 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 613 1 499 1 211 1 2927 1 1 1327 1 1 1123 1 907 1 2543 1 1 1 311 2683 1 1 1 1 2963 1 1 1 641 761 1 1 1 1 1 1 1 1 1 1 1 1489 2857 1 1 1 1 1 1 1 1 1 1 1 1 1 967 1 821 1 1 1 1 2143 1861...

output:


result: