SDNU_ACM_ICPC_2017_Winter_Practice_2th

哇这次只做了几个题待我慢慢补。。
最主要的还是数论。。


A ZOJ 1586 QS Network

这个题超超说先不做而且题目竟然打不开了woc链接暂时挂不上去。


B HDU 1061 Rightmost Digit

快速幂(找规律)

输入N输出N^N的个位数。

第一遍做成了找规律后来聪神说是快速幂23333。

快速幂就是N^N对10取余。
找规律的话有一点2的幂个位有2 4 8 6四种这里只用到了4 6因为是N^N当N的个位是2的时候%4肯定不会得出1和3所以就不用考虑2和8的情况了。

首先是快速幂的代码

/*********************
author : MengFanzhuang
*********************/

#include <cstdio>
#include <iostream>
using namespace std;

long long Pow(long long a,long long b,long long c)
{
    long long r=1,base=a;
    while(b!=0)
    {
        if(b&1)
            r=r*base%c;
        base=base*base%c;
        b>>=1;
    }
    return r;
}
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        while(n--)
        {
            int a;
            scanf("%d",&a);
            cout<<Pow(a,a,10)<<endl;
        }
    }
    return 0;
}

然后是找规律的。

/*********************
author : MengFanzhuang
*********************/

#include <cstdio>
#include <iostream>
using namespace std;

int main()
{
    int N;
    while(scanf("%d",&N)!=EOF)
    {
        for(int j=0;j<N;++j)
        {
            int a,b;
            scanf("%d",&a);
            b=a%10;
            if(b==0)
            {
                cout<<"0"<<endl;
            }
            else if(b==1)
            {
                cout<<"1"<<endl;
            }
            else if(b==2)
            {
                if(a%4==2)cout<<"4"<<endl;
                else cout<<"6"<<endl;
            }
            else if(b==3)
            {
                if(a%4==1)cout<<"3"<<endl;
                else cout<<"7"<<endl;
            }
            else if(b==4)
            {
                cout<<"6"<<endl;
            }
            else if(b==5)
            {
                cout<<"5"<<endl;
            }
            else if(b==6)
            {
                cout<<"6"<<endl;
            }
            else if(b==7)
            {
                if(a%4==1) cout<<"7"<<endl;
                else cout<<"3"<<endl;
            }
            else if(b==8)
            {
                if(a%4==2) cout<<"4"<<endl;
                else cout<<"6"<<endl;
            }
            else if(b==9)
            {
                cout<<"9"<<endl;
            }
        }
    }
    return 0;
}

C POJ 2773 Happy 2006


D POJ 1284 Primitive Roots


E HDU 1087 Super Jumping! Jumping! Jumping!

动态规划

SDNU 1221 ||SDNU1292 这两个类似的一个题。
不过感觉自己写的dp和别人的不太一样啊。

/*********************
author : MengFanzhuang
*********************/

#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
bool cmp(int a,int b)
{
    return a>b;
}
int main()
{
    int N;
    while(scanf("%d",&N)!=EOF&&N)
    {
        int a[1005]={0},b[1005]={0};
        for(int j=0;j<N;++j)
        {
            scanf("%d",&a[j]);
            b[j]=a[j];
        }
        for(int i=1;i<N;++i)
        {
            for(int j=0;j<i;++j)
            {
                if(a[i]>a[j]&&b[i]<b[j]+a[i])
                {
                    b[i]=b[j]+a[i];
                }
            }
        }
        sort(b,b+N,cmp);
        cout<<b[0]<<endl;
    }
    return 0;
}

F POJ 3358 Period of an Infinite Binary Expansion


G POJ 3167 Cow Patterns

KMP


H POJ 1365 Prime Land


I HDU 2773 White Water Rafting


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值