Codeforces Round #326 (Div. 2)
来源:互联网 发布:淘宝高手全本阅读 编辑:程序博客网 时间:2024/05/21 06:30
这场时间太晚偷懒没做。。昨天补了一下发现痛失涨分机会,权当为区域赛攒人品了囧。。
A - Duff and Meat
维护当前最低价,每天都以最低价购买所需食物。
B - Duff in Love
输出n的素因数之积即可。
C - Duff and Weight Lifting
统计每一等级重量的数目,然后转换成二进制,再统计二进制数有多少个1.
D - Duff in Beach
题意:
有数组
a[0…n−1] 和数组b[0…l−1] ,
其中b[i]=a[i%n] ,
求在数组b[0…l−1] 中其满足下列3个条件的序列数目 。
设序列为bi1,bi2,…,bix ,那么:
1.1≤x≤k ,即序列最多有k个数;
2. 把数组分为n块,序列中的相邻两个数在相邻块里;
3. 序列为不下降序列。
思路:
题意和和官方题解都是绕来绕去的,英语渣表示so bad。。
由题意可知,b数组的数最多用到前 n * k 个,于是把前 n * k 个数与其下标 i 存入 pair 数组中然后排序。遍历该数组,用 dp[i] 表示以第 i 个数结尾的序列有多少个 , 转移方程为:
又因为类似序列有 ( l - i + n - 1 ) / n 个 ,所以答案就是:
值得一提的是 ( l - i + n - 1 ) / n 这个数会很大,先模除再运算。
代码:
//2015/10/21 21:32:42//#pragma comment(linker, "/STACK:102400000,102400000")#include<iostream>#include<cstdio>#include<cstring>#include<cstdlib>#include<cmath>#include<algorithm>#include<functional>#include<string>#include<map>#include<set>#include<vector>#include<queue>#include<stack>#include<bitset>#include<ctime>using namespace std;#define clr( x , y ) memset(x,y,sizeof(x))#define cls( x ) memset(x,0,sizeof(x))#define pr( x ) cout << #x << " = " << x << endl #define pri( x ) cout << #x << " = " << x << " " #define test( t ) int t ; cin >> t ; int kase = 1 ; while( t-- )#define out( kase ) printf( "Case %d: " , kase++ )#define sqr( x ) ( x * x )#define mp make_pair#define pii pair<lint,lint>#define fi first#define se second#define pb push_backtypedef long long lint;const double eps = 1e-8 ;const int inf = 0x3f3f3f3f ;const long long INF = 0x3f3f3f3f3f3f3f3fLL ;const int N = 1e6 + 5 ;const int MOD = 1e9 + 7 ;lint dp[N] , a[N] ;vector<pii > p ;lint n , k , l ;int main(){ //freopen("my.in","r",stdin); //freopen("my.out","w",stdout); while ( cin >> n >> l >> k ) { for ( int i = 0 ; i < n ; i++ ) scanf( "%I64d" , a + i ) ; p.clear() ; cls( dp ) ; for ( int i = 0 ; i < n * k ; i++ ) p.pb( mp( a[i%n] , i ) ) ; sort( p.begin() , p.end() ) ; lint tmp , ans = 0 ; for ( int i = 0 ; i < n * k ; i++ ) { lint pos = p[i].se ; tmp = ( pos < n )? 1LL : dp[pos/n - 1] ; dp[pos/n] = ( dp[pos/n] + tmp ) % MOD ; if ( pos < l ) { lint x = ( l - pos + n - 1 ) / n ; ans = ( ans + tmp * ( x % MOD ) ) % MOD ; } } cout << ans << endl ; } return 0;}
0 0
- Codeforces Round #326 (Div. 2)
- Codeforces Round #326 (Div. 2)
- Codeforces Round #326 (Div. 2)
- Codeforces Round #326 (Div. 2)
- Codeforces Round #326 (Div. 2)
- Codeforces Round #326 (Div. 2) B
- Codeforces Round #326 (Div. 2) A
- Codeforces Round #326 (Div. 2)总结
- Codeforces Round #326 (Div. 2) C
- Codeforces Round #102 (Div. 2)
- Codeforces Round #103 (Div. 2)
- Codeforces Round #103 (Div. 2)
- Codeforces Round #104 (Div. 2)
- Codeforces Round #105 (Div. 2)
- Codeforces Round #105 (Div. 2)
- Codeforces Round #107 (Div. 2)
- Codeforces Round #108 (Div. 2)
- Codeforces Round #110 (Div. 2)
- ScrollView自动布局
- 语音课程
- Under the Hood: Rebuilding Facebook for Android
- 满足条件的周长最短的三条边
- 建造模式
- Codeforces Round #326 (Div. 2)
- Under the Hood: Dalvik patch for Facebook for Android
- iOS9 出现 the resource could not be loaded because the app transport security policy requires the use
- mysql管理
- 数据挖掘之路一个月零十天有感
- Android实现AirPlay,DriodAirPlay开发
- [BZOJ1026][SCOI2009]windy数
- unity3d Vector3.Dot Cross Angle 用法记录
- Windows程序设计--文本输出(一)