https://www.cnblogs.com/zhengguiping--9876/p/6015019.html LightOj 1213 - Fantasy of a Summation(推公式 快速幂) 我们很容易就知道最内层的加法式子执行了n^K次,每次加了K个数,所以一共加了K*n^K个数,一共有n个数,每个数加的次数一定是相同的,所以每个数都加了K*n^(K-1)次,所以结果就是Sum*K*n^(K-1)%mod; 快速幂求一下即可:…
http://lightoj.com/volume_showproblem.php?problem=1213  Fantasy of a Summation Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Status Practice LightOJ 1213 Description If you think codes, eat codes then sometimes you…
题目链接:http://lightoj.com/volume_showproblem.php?problem=1213 #include <stdio.h> int cases, caseno; int n, K, MOD; int A[1001]; int main() { scanf("%d", &cases); while( cases-- ) { scanf("%d %d %d", &n, &K, &MOD); i…
1213 - Fantasy of a Summation         If you think codes, eat codes then sometimes you may get stressed. In your dreams you may see huge codes, as I have seen once. Here is the code I saw in my dream. #include <stdio.h> int cases, caseno;int n, K, M…
题目链接:https://vjudge.net/problem/LightOJ-1213 1213 - Fantasy of a Summation    PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB If you think codes, eat codes then sometimes you may get stressed. In your dreams you may see hug…
/** 题目:Fantasy of a Summation 链接:https://vjudge.net/contest/154246#problem/L 题意:n个数,k层重复遍历相加.求它的和%mod的值: 思路:很容易想到n个数出现在要加的和中的次数相同. 又所有数的出现次数为n^k * k: 所以每个数出现的次数为n^k * k / n; */ #include<iostream> #include<cstring> #include<cstdio> #inclu…
题意: 首先 只看第一层循环的A[0],是不是用了nk-1次  A[1]也是用了nk-1次······ 所以 第一层的sum(A[i]的和) 一共用了nk-1 所以第一层为sum * nk-1 因为又k层循环 所以全部为sum * nk-1 * k 最后不要忘了 % MOD 代码如下: #include <iostream> #include <cstdio> #include <cmath> #include <algorithm> #define mem…
题解:根据题目给的程序,就是计算给的这个序列,进行k次到n的循环,每个数需要加的次数是k*n^(k-1),所以快速幂取模,算计一下就可以了. #include <bits/stdc++.h> using namespace std; typedef long long ll; const int INF = 0x3f3f3f3f3f; long long pow_mod(ll a, ll k, ll mod) { ll ans = 1; while(k) { if(k%2) ans *= a;…
块的计数 Time Limit: 10 Sec  Memory Limit: 256 MBSubmit: 455  Solved: 261[Submit][Status][Discuss] Description 小Y最近从同学那里听说了一个十分牛B的高级数据结构——块状树.听说这种数据结构能在sqrt(N)的时间内维护树上的各种信息,十分的高效.当然,无聊的小Y对这种事情毫无兴趣,只是对把树分块这个操作感到十分好奇.他想,假如能把一棵树分成几块,使得每个块中的点数都相同该有多优美啊!小Y很想知…
链接: https://vjudge.net/problem/LightOJ-1299 题意: 考虑成,U位置的点要往后放,D位置往前放 Dp[i][j]表示处于i位置,还有j个U没有放下. s[i] == 'D' : Dp[i][j] = Dp[i-1][j]j+Dp[i-1][j+1](j+1) 把d放到前面空出来j的位置中的一个,或者是j+1中的一个同时j+1中的一个U再放下来. s[i] == 'U' : Dp[i][j] = Dp[i-1][j-1]+Dp[i-1][j]*j 拿起当前…