zoukankan      html  css  js  c++  java
  • usaco-3.2-fact4-pass

    这个是数论知识,列举一下前面十几个就可以看出规律:

    /*
    ID: qq104801
    LANG: 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 Training
    Grader Results     
    8 users online
    CHN/2 DNK/1 GRC/1 IND/1 SGP/1 TUR/1 USA/1
    
    USER: cn tom [qq104801]
    TASK: fact4
    LANG: C++
    
    Compiling...
    Compile: OK
    
    Executing...
       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 ----
    1000
    
    Keep up the good work!
    Thanks for your submission!
    /***********************************************

    看书看原版,原汁原味。

    不会英文?没关系,硬着头皮看下去慢慢熟练,才会有真正收获。

    没有原书,也要网上找PDF来看。

    网上的原版资料多了去了,下载东西也到原始下载点去看看。

    你会知其所以然,呵呵。

    ***********************************************/

  • 相关阅读:
    Maven 安装 / 常用配置 / 阿里maven中央仓库
    记录:框架
    Mysql配置文件详解 my.cof
    Vmware虚拟机设置静态IP地址
    虚拟机安装centos发现inet为127.0.0.1,导致Xshell连接不上
    Servlet小案例总结
    Win10 提升系统响应速度
    从顶端插入,滚动展示(Demo):
    eclipse +cygwin+C++
    大型网站技术学习-3. 容器Docker与kubernetes
  • 原文地址:https://www.cnblogs.com/dpblue/p/3966737.html
Copyright © 2011-2022 走看看