# 《孫子算經》 ## 孫子問題 今有物不知其數,三三數之剩二,五五數之剩三,七七數之剩二,問物幾何? ```cpp= /** *** Author: R-CO *** E-Mail: daniel1820kobe@gmail.com *** Date: 2020-09-25 **/ #include <vector> using std::vector; vector<int> nums = { 0 }; int SunAccounting(int n) { int try_num = nums[nums.size() - 1] + 1; while (nums.size() <= n) { if ((try_num % 3 == 2) && (try_num % 5 == 3) && (try_num % 7 == 2)) { nums.push_back(try_num); } ++try_num; } return nums[n]; } ``` ###### tags: `puzzle` `C++`