450A - Jzzhu and Children 找规律也可以模拟
2014-07-21 19:41
344 查看
挺水的一道题,规律性很强,在数组中找出最大的数max,用max/m计算出倍数t,然后再把数组中的书都减去t*m,之后就把数组从后遍历找出第一个大于零的就行了
#include<iostream> #include<stdio.h> using namespace std; int main(){ // freopen("in.txt","r",stdin); int a[105],n,m; while(~scanf("%d%d",&n,&m)){ int max=0; for(int i=0;i<n;i++){ scanf("%d",&a[i]); if(a[i]>max) max=a[i]; } int t=max/m; if(max%m==0) t--; for(int i=0;i<n;i++){ a[i]-=t*m; } int ans=-1; for(int i=n-1;i>=0;i--){ if(a[i]>0){ ans=i; break; } } if(t==0) cout<<n<<endl; else cout<<ans+1<<endl; } }
相关文章推荐
- 450A - Jzzhu and Children 找规律也能够模拟
- Codeforces Round #257 (Div. 2) 450A - Jzzhu and Children(模拟)
- codeforces 450A Jzzhu and Children
- Jzzhu and Children - CF 450A 水题
- (CF#257)A. Jzzhu and Children
- Codeforces Round #257 (Div. 2) E题:Jzzhu and Apples 模拟
- Codeforces Round #257 (Div. 2)1A Jzzhu and Children
- codeforces 425B Sereja and Table(状态压缩,也可以数组模拟)
- Jzzhu and Children
- Chapter 3 | Stacks and Queues--实现数据结构模拟一个栈由几个子栈组成,并可以在指定子栈上进行出栈操作
- Codeforces Round #257 (Div. 2/A)/Codeforces450A_Jzzhu and Children
- Codeforces Round #257 (Div. 2) A. Jzzhu and Children
- Codeforces Round #257 (Div. 2) A. Jzzhu and Children
- Codeforces Round #257 (Div. 2)A. Jzzhu and Children
- Codeforces Div. 2 #257-A. Jzzhu and Children
- HDU - 4001 To Miss Our Children Time (模拟)可以放多高的砖
- A. Jzzhu and Children
- Codeforces Round #257 (Div. 2/A)/Codeforces450A_Jzzhu and Children
- Codeforces Round #257 (Div. 2) A. Jzzhu and Children
- Jzzhu and Children