1 #include<stdio.h> 2 3 int main(void) 4 { 5 int n, m; 6 int i; 7 int isPrime; 8 int sum; 9 int count; 10 11 i = 2; //第一个素数 12 sum = 0; 13 count = 0; //符合条件的素数个数 14 scanf_s("%d %d", &n, &m); 15 16 do 17 { 18 isPrime = 1; 19 20 for (int j = 2; j < i; j++) 21 { 22 if (i % j == 0) 23 { 24 isPrime = 0; 25 break; 26 } 27 } 28 29 if (isPrime) 30 { 31 count++; 32 33 if (count >= n) 34 { 35 sum = sum + i; 36 } 37 } 38 39 i++; 40 } while (count < m); 41 42 printf("%d ", sum); 43 44 return 0; 45 }