B. Wonderful Array

                                                        B. Wonderful Array

Problem - B - Codeforces

 

思路:我们需要求的是bi<=bi+1的个数,对于i=[0,n-1],我们求这个个数其实是不好求的,即使是=的个数就是求有多少个位置b[i]%m==0,好像也不是那么容易求得,所以我们可以考虑一下,如果我们能够求出来>的个数,那么其实就是可以求出来<=的个数了,首先x跟b0,b1,...,bn-1如果是大于m的,那么其实只有对m的余数是有用的,所以我们可以对x,b0,b1....bn-1都对m取余,而着就出现了一个有趣的问题,如果我们从头开始计算直到计算到bn,假设当前是第i个,并且i-1的值为res,那么当前的值为res+a[i%k],那么有趣的现象来了,如果这个值是比m大的,那么它在对m取模之后是一定比res小的,因为我们加上的这个数a[i%k]是比m小的,所以这个结果是res%m>(res+a[i%k])%m,所以这是一个>的合法解,然后我们又发现了,只要我们找到了所有的这种情况,那么其实就是>的所有的解,而又有一个有趣的事,因为我们每次加的都是比m小的,所以只要bn中有几个m的倍数,就会出现几个这种>情况,所以我们只需要求出来bn是多少,然后除m就是>的情况,所以n-bn/m就是<=的情况

// Problem: B. Wonderful Array
// Contest: Codeforces - 2023 (ICPC) Jiangxi Provincial Contest -- Official Contest
// URL: https://codeforces.com/gym/104385/problem/B
// Memory Limit: 512 MB
// Time Limit: 1000 ms

#include<iostream>
#include<cstring>
#include<string>
#include<sstream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<vector> 
#include<set>
#include<unordered_map>
#include<ctime>
#include<cstdlib>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> PII;
typedef pair<int,pair<int,int> > PIII;
const double eps=1e-7;
const int N=1e6+7 ,M=5e5+7, INF=0x3f3f3f3f,mod=1e9+7;
const long long int llINF=0x3f3f3f3f3f3f3f3f;
inline ll read() {ll x=0,f=1;char c=getchar();while(c<'0'||c>'9') {if(c=='-') f=-1;c=getchar();}
while(c>='0'&&c<='9') {x=(ll)x*10+c-'0';c=getchar();} return x*f;}
inline void write(ll x) {if(x < 0) {putchar('-'); x = -x;}if(x >= 10) write(x / 10);putchar(x % 10 + '0');}
inline void write(ll x,char ch) {write(x);putchar(ch);}
void stin() {freopen("in_put.txt","r",stdin);freopen("my_out_put.txt","w",stdout);}
bool cmp0(int a,int b) {return a>b;}
template<typename T> T gcd(T a,T b) {return b==0?a:gcd(b,a%b);}
template<typename T> T lcm(T a,T b) {return a*b/gcd(a,b);}
void hack() {printf("\n----------------------------------\n");}

int T,hackT;
int n,m,k;
ll w[N];
int vis[N];

void solve() {
	k=read();
	
	for(int i=0;i<k;i++) vis[i]=read();
	n=read(),m=read();
	int x=read();
	
	x=x%m;
	for(int i=0;i<k;i++) vis[i]=vis[i]%m;

	w[0]=x;
	for(int i=1;i<=k;i++) w[i]=w[i-1]+vis[i-1];
	
	int t=(n/k)*k;
	ll sum=w[k]-w[0];
	ll res=(ll)sum*(n/k)+x;
	for(int i=t+1;i<=n;i++) res+=vis[i-t-1];
	
	int ans=n-res/m;
	
	printf("%d\n",ans);
}   

int main() {
    // init();
    // stin();

    // scanf("%d",&T);
    T=1; 
    while(T--) hackT++,solve();
    
    return 0;       
}          

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
听力部分(20分) Ⅰ.看图听对话,选择与对话意思一致的图画。每个对话读一遍。(5分) 1. 2. 3. 4. 5. Ⅱ.情景反应。听录音,根据你所听到的句子,选择恰当的答语。每个句子读两遍。(5分) ( ) 6. A. Thank you. B. Good idea! C. Never mind. ( ) 7. A. Some water. B. A handbag. C. Fried rice. ( ) 8. A. Have a good trip! B. You’re all right. C. Go slowly. ( ) 9. A. This way, please. B. Thank you. C. Here you are. ( ) 10.A. Not at all. B. With pleasure. C. My pleasure.   Ⅲ.对话理解。听对话,根据问题选择最佳答案。每段对话读两遍。(5分) ( ) 11. What is Davy doing? A. Parking his car. B. Cleaning his car. C. Repairing his car. ( ) 12. When does he wear his uniform? A. On weekends. B. On Sundays. C. On weekdays. ( ) 13. How much are three cups? A. Four. B. Twelve. C. Ten. ( )14. What does Lily like to drink? [来源:21世纪教育网] A. A cup of tea with milk. B. A glass of orange juice. C. Coffee. ( ) 15. Why didn’t Brown go to play football with us yesterday? A. Because he was ill. B. Because he wanted to have a rest.21世纪教育网 C. Because he was busy. Ⅳ.听短文,选择正确答案。短文读两遍。(5分) ( )16. Linda comes from _________. A. Canada B. Amercia C. France ( ) 17. She was good at _________. A. traveling B. science C. computers ( ) 18. She liked Paris best because it was __________. A. traditional and beautiful B. beautiful and modern C. modern and wonderful ( ) 19. Her family will go to Hainan __________. A. by ship B. by air C. by car ( ) 20. They will stay in Hainan for _______days. A. 5 B. 6 C. 7 笔试部分 (80分) Ⅴ.选择填空。(15分) A) 单词辨音。找出画线部分发音不同的选项。 ( ) 21. A. bill B. size C. silver ( ) 22. A. huge B. menu C. push ( ) 23. A. warn B. scarf C. hardly
github地址:https://github.com/dsxNiubility/Wonderful 代码还在不断更新中,建议继续关注代码库 一、UIColor Wonderful 1.这个分类里扩充了更多的颜色扩展,以后随手写个小Demo再也不需要redColor buleColor了。 2.平均每个色系有10种颜色,不仅可以使用名称直接敲出,还能使用颜色阶梯的宏敲出,在你想不起词的时候更加方便。 宏从1~10是颜色渐深,可以根据自己的感觉使用浅一级的宏或深一级的宏。 3.提供了颜色微调方案,可以让一个已知颜色的rgb的某值上升或下降若干,可用于不管背景是什么色,边框都比背景深20。 也可以将认可颜色的详细值打印出来。 二、UIColor Separate 1.提供颜色分离方案,可以将任何颜色的rgb喝alpha的值取出。 2.可以通过一个颜色算出此颜色的反色,使得背景无论被用户设置成什么色,文字颜色都是背景的反色。 3.也可以直接打印这个颜色的各项详细数值。 三、SXColorGradientView 1.颜色渐变的view,可以设置任何颜色到透明的过渡。 2.也可以设置两个颜色相互过渡。 3.可以设置向上下左右四个过渡的方向。 *4.后续会增加传入一个数组,然后搭建一个多个颜色过渡的view。 四、SXMarquee 1.实现任何样式的跑马灯。 2.跑马灯的背景可以设置任何颜色,这个是基于颜色过渡view做的。 3.跑马灯可以实现点击拖动,或者绑定更多点击事件。 博客地址:http://www.cnblogs.com/dsxniubility/ github地址:https://github.com/dsxNiubility

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值