Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
60979 冯纪尧 19神秘数字 C++ Compile Error 0 MS 0 KB 830 2023-11-25 15:58:24

Tests(0/0):


Code:

#include <stdio.h> #include <stdbool.h> // 求解模运算 int modulo(int a, int b) { return a % b; } bool is_solution(int n) { int a; // 自然数被8除余1 a = modulo(n, 8); if (a != 1) { return false; } // 商被8除也余1 a = modulo(n / 8, 8); if (a != 1) { return false; } // 第二次的商被8除后余7 a = modulo((n / 8) / 8, 8); if (a != 7) { return false; } // 自然数被17除余4 a = modulo(n, 17); if (a != 4) { return false; } // 所得的商被17除余15 a = modulo(n / 17, 17); if (a != 15) { return false; } // 最后得到一个商是a,即 (n/17)/8 ≡ a (mod 8) a = modulo((n / 17) / 8, 8); return a == 1; } int main() { int n; for (n = 1; n <= 1000000; n++) { if (is_solution(n)) { printf("找到满足条件的自然数:%d ", n); break; } } return 0; }


Run Info:

Main.cc:42:8: warning: missing terminating " character
 printf("找到满足条件的自然数:%d
        ^
Main.cc:42:1: error: missing terminating " character
 printf("找到满足条件的自然数:%d
 ^
Main.cc:43:1: warning: missing terminating " character
 ", n);
 ^
Main.cc:43:1: error: missing terminating " character
Main.cc: In function 'int main()':
Main.cc:44:1: error: expected primary-expression before 'break'
 break;
 ^