loj10195. 「一本通 6.1 练习 2」转圈游戏 (loj2608)

思路:
  简单的数学题。

#include<cstdio>
#include<iostream>
using namespace std;
long long quickpow(long long a, long long b, long long p){
    long long res = 1;
    while(b){
        if(b & 1)    res = res * a % p;
        a = a * a % p;
        b >>= 1;
    }
    return res;
}
long long n, m, k, x;
int main(void){
    cin >> n >> m >> k >> x;
    cout << (x + ((m % n) * quickpow(10, k, n)) % n) % n << endl;
}

原文地址:https://www.cnblogs.com/junk-yao-blog/p/9505513.html

时间: 2024-08-30 17:40:13

loj10195. 「一本通 6.1 练习 2」转圈游戏 (loj2608)的相关文章

loj10164. 「一本通 5.3 例 2」数字游戏

思路: 既然是数位dp,先写两个函数分别求一个十进制数值的指定位和该数的位数. 设f[i][j]为用i个数字单调不降地填满j个位置,初始化f[i][0]=1(i从1到10),转移方程f[i][j] = . 然后按定义累加即可. #include<cstdio> #include<iostream> #include<cstring> #include<string> #include<cmath> using namespace std; con

10249「一本通 1.3 例 5」weight

#10249「一本通 1.3 例 5」weight 题目描述 原题来自:USACO 已知原数列a1,a2,...,an中的前1项,前2项,前3项,... ,前 n 项的和,以及后 1 项,后 2 项,后 3 项,...,后 n 项的和,但是==所有的数都被打乱了顺序==.此外,我们还知道数列中的数存在于集合 S 中.试求原数列.当存在多组可能的数列时,求字典序最小的数列. 输入格式 第 1 行,一个整数 n . 第 2 行, 2 × n 个整数,注意:数据已被打乱. 第 3 行,一个整数 m ,

「一本通 4.1 练习 2」简单题

题目描述 题目来源:CQOI 2006 有一个 n 个元素的数组,每个元素初始均为 0.有 m 条指令,要么让其中一段连续序列数字反转--0 变 1,1变 0(操作 1),要么询问某个元素的值(操作 2). 例如当 n=20 时,10 条指令如下: 操作 回答 操作后的数组 1 1 10 N/A 11111111110000000000 2 6 1 11111111110000000000 2 12 0 11111111110000000000 1 5 12 N/A 11110000001100

「一本通 4.2 例 2」最敏捷的机器人(loj10120)

题目描述 Wind 设计了很多机器人.但是它们都认为自己是最强的,于是,一场比赛开始了-- 机器人们都想知道谁是最敏捷的,于是它们进行了如下一个比赛.首先,他们面前会有一排共 n 个数,它们比赛看谁能最先把每连续 k 个数中最大和最小值写下来,当然,这些机器人运算速度都很快,它们比赛的是谁写得快. 但是 Wind 也想知道答案,你能帮助他吗? 输入格式 第一行为 n,k,意义如题目描述. 第二行共 n 个数,为数字序列,所有数字均在 Pascal 的 longint 范围内,即所有数均为整数,且

loj10139. 「一本通 4.5 练习 1」树上操作(loj2125. 「HAOI2015」树上操作 )

思路: 第二遍dfs时记录end[x]为在结点序列中以x为根的子树最后访问的节点,写个线段树标记下传即可.与值有关的数据注意long long #include<cstdio> #include<iostream> #include<vector> #include<cmath> #include<string> using namespace std; const int maxn = 100010; inline void qread(int

loj10143. 「一本通 4.6 例 1」营业额统计

思路: 使用treap在线存数据,每次取出新读入数据的前驱与后继,与该数据差值较小的就是.(注意若已有同一个数据,特判ans+=0) #include<cstdio> #include<iostream> #include<cstdlib> #include<cmath> using namespace std; const int maxn = 100010; inline void qread(int &x) { x = 0; register

loj10144. 「一本通 4.6 练习 1」宠物收养所

思路: treap+简单模拟. 我只能说:注意取模!!!! #include<cstdio> #include<iostream> #include<cstdlib> #include<cmath> using namespace std; const int maxn = 80010; inline void qread(int &x) { x = 0; register int ch = getchar(), flag = 0; while(ch

loj10145. 「一本通 4.6 练习 2」郁闷的出纳员

思路: 简单的treap+模拟. 但这道题的题面有误导群众的嫌疑,因为题中并没有明确刚进入公司就离开的算不算在离开公司的人中. 当然,对于这道题的数据,题目意思是不算在内. #include<cstdio> #include<iostream> #include<cstdlib> #include<string> using namespace std; const int maxn = 80010; inline void qread(int &x

loj10141. 「一本通 4.5 练习 3」染色

思路: 利用树链剖分转化为线段树问题,考虑线段上经这两种操作后的sum求值方法,并着重考虑树链合并的情况即可.线段树为了打cov,要注意将所有的颜色统一加一. #include<cstdio> #include<iostream> using namespace std; const int maxn = 100010; inline void qread(int &x){ x = 0; register int ch = getchar(); while(ch <