Ji Suanke 2019 Blue Bridge Cup National Championship Group B Simulation Label (Fill in the blank)

Summary of questions and solutions for the 2019 Blue Bridge Cup National Championship Group B mock competition:

https://blog.csdn.net/daixinliangwyx/article/details/90231587

 

first question

Title: Label


Solution: It is enough to multiply the past step by step, because as long as the last six digits of the result, you don't need to record the result of each step completely, and keep a few more digits than the six digits, and you can retain seven digits, that is, after each multiplication, % 10000000.

Code:

#include<bits/stdc++.h>
using namespace std;
int main() {
  long long ans = 1;
  for (long long i = 2; i <= 1325476; i++) {
    ans *= i;
    while (ans % 10 == 0)
      ans /= 10;
    ans %= 10000000;
  } 
  printf("%06lld\n", ans);
  return 0;
}

Answer: 137664

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326568080&siteId=291194637