Usaco-3.2-fact4-pass

Source: Internet
Author: User

This is the number theory knowledge. Let's look at the first 10 rules:

/*ID: qq104801LANG: C++TASK: fact4*/#include <iostream>#include <fstream>#include <cstring>#include <vector>#include <map>#include <list>#include <set>#include <queue>#include <cstdio>#include <algorithm>#include <cmath>using namespace std;void test(){        freopen("fact4.in","r",stdin);    freopen("fact4.out","w",stdout);    int n;    cin>>n;    int m=1,pp=100000,f;    for(int i=1;i<=n;i++)    {        f=i%pp;        m*=f;        while(m%10==0)            m/=10;        while(m/pp>0)            m%=pp;    }    cout<<m%10<<endl; }int main () {            test();            return 0;}

Test data:

USACO TrainingGrader Results     8 users onlineCHN/2 DNK/1 GRC/1 IND/1 SGP/1 TUR/1 USA/1USER: cn tom [qq104801]TASK: fact4LANG: C++Compiling...Compile: OKExecuting...   Test 1: TEST OK [0.005 secs, 3372 KB]   Test 2: TEST OK [0.005 secs, 3372 KB]   Test 3: TEST OK [0.005 secs, 3372 KB]   Test 4: TEST OK [0.005 secs, 3372 KB]   Test 5: TEST OK [0.008 secs, 3372 KB]   Test 6: TEST OK [0.005 secs, 3372 KB]   Test 7: TEST OK [0.011 secs, 3372 KB]   Test 8: TEST OK [0.008 secs, 3372 KB]   Test 9: TEST OK [0.008 secs, 3372 KB]   Test 10: TEST OK [0.008 secs, 3372 KB]All tests OK.YOUR PROGRAM (‘fact4‘) WORKED FIRST TIME! That‘s fantastic -- and a rare thing. Please accept these special automated congratulations.Here are the test data inputs:------- test 1 ----1------- test 2 ----2------- test 3 ----7------- test 4 ----14------- test 5 ----143------- test 6 ----645------- test 7 ----777------- test 8 ----888------- test 9 ----999------- test 10 ----1000Keep up the good work!Thanks for your submission!

 

Usaco-3.2-fact4-pass

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.