zoukankan      html  css  js  c++  java
  • 【noip系列——数论】转圈游戏

     P1965 转圈游戏

      noip2013 day1T1

      刚开始看错题信心满满的提交——>全WA——>然后发现自己看错题了QAQ

      然后就发现了一个很“显然”的事情, 只需要计算(x+10k * m)%n 的值即可;

      Soga√ 来复习一下取模的性质:

      

      来复习一下快速幂√ 

      好啦贴代码qwq

     1 #include<cstdio>
     2 #include<iostream>
     3 #define ll long long
     4 using namespace std;
     5 ll n,m,k,x, ans = 1;
     6 void qsm(int x, int y) {
     7     while(y>0) {
     8         if(y&1) ans = ans*x%n;
     9         x = x*x%n;
    10         y = y>>1;
    11     }
    12 }
    13 int main() {
    14     scanf("%lld%lld%lld%lld",&n,&m,&k,&x);
    15     qsm(10,k);
    16     ans = (x%n+(ans%n)*(m%n))%n;
    17     printf("%lld",ans);
    18     return 0;
    19 }

      写在最后:noip冲鸭!!!!!!!!!!!!!!!!!!!!!

    总之岁月漫长,然而值得期待。
  • 相关阅读:
    抽象类
    类初始化
    final关键字
    super关键字
    继承
    常用类

    封装
    方法重载
    031:Cetus sharding
  • 原文地址:https://www.cnblogs.com/Hwjia/p/9758667.html
Copyright © 2011-2022 走看看