zoukankan      html  css  js  c++  java
  • 快速幂且看

    1.

     https://cn.vjudge.net/contest/317382#problem/E

    人见人爱A^B

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    ll a,b;
    ll qmod(ll a,ll b,ll m)
    {
    	ll ans=1;
    	while(b)
    	{
    		if(b&1) ans=ans*a%m;
    		a=a*a%m;
    		b>>=1;
    	}
    	return ans;
    }
    int main()
    {
    	while(cin>>a>>b && (a||b))
    		cout<<qmod(a,b,1000)<<"
    ";
    	return 0;
    }
    

    2.

    Rightmost Digit

     https://cn.vjudge.net/contest/317382#problem/D

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    ll t,a;
    ll qmod(ll a,ll b,ll m)
    {
    	ll ans=1;
    	while(b)
    	{
    		if(b&1) ans=ans*a%m;
    		a=a*a%m;
    		b>>=1;
    	}
    	return ans;
    }
    int main()
    {
    	cin>>t;
    	while(t--)
    	{
    		cin>>a;
    		cout<<qmod(a,a,10)<<endl;
    	}
    	return 0;
    }
    

    3.

    https://cn.vjudge.net/contest/317382#problem/A4.

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    ll a,b,m;
    ll qmod(ll a,ll b,ll m)
    {
    	ll ans=1;
    	while(b)
    	{
    		if(b&1) ans=ans*a%m;
    		a=a*a%m;
    		b>>=1;
    	}
    	return ans;
    }
    int main()
    {
    	int t;
    	cin>>t;
    	while(t--)
    	{
    		cin>>a>>b>>m;
    		cout<<qmod(a,b,m)<<endl;
    	}
    	return 0;
    }
    

      

    4.

    Raising Modulo Numbers

     https://cn.vjudge.net/contest/317382#problem/B

    #include<iostream>
    #include<cstdio>
    using namespace std;
    typedef long long ll;
    ll T,M,H,a,b,res;
    ll qmod(ll a,ll b,ll m)
    {
    	ll ans=1;
    	while(b)
    	{
    		if(b&1) ans=ans*a%m;
    		a=a*a%m;
    		b>>=1;
    	}
    	return ans;
    }
    int main()
    {
    	scanf("%lld",&T);
    	while(T--)
    	{
    		res=0;
    		scanf("%lld%lld",&M,&H);
    		while(H--)
    		{
    			scanf("%lld%lld",&a,&b);
    			res=(res+qmod(a,b,M))%M;
    		}
    		printf("%lld
    ",res);
    	}
    	return 0;
    }
    

      

    5.

    这是一道难题:ZOJ1333

    https://cn.vjudge.net/contest/317382#problem/C

  • 相关阅读:
    linux文件属性基础篇
    Linux重定向符号(重点)
    linux---vim和grep
    linux目录文件与系统启动(3)/usr目录、/var目录和/proc目录讲解
    Linux 安装和 连接xshell
    shiro 快速入门详解。
    th 表达式的简单使用。
    springboot 分布式项目,子级项目各自的作用。
    springboot 配置百里香 thymeleaf?
    springboot 配置mybatis 配置mapper.xml
  • 原文地址:https://www.cnblogs.com/dragondragon/p/11321995.html
Copyright © 2011-2022 走看看