ccf 除法
来源:互联网 发布:淘宝中学生书包女韩版 编辑:程序博客网 时间:2024/05/22 06:58
#include<stdio.h>#include<iostream>#include<string.h>#define ll long longusing namespace std;ll num[100050];ll c[100050];ll n,m;ll lowbit(ll i){ return i&(-i);}void add(int i,ll val){ for(i; i<=n; i+=lowbit(i)) { c[i]+=val; } return;}ll sum(ll i){ ll he=0; for(i; i>0; i-=lowbit(i)) { he+=c[i]; } return he;}int main(){ memset(c,0,sizeof(c)); scanf("%lld%lld",&n,&m); for(int i=1; i<=n; i++) { scanf("%lld",&num[i]); add(i,num[i]); } ll k,x,y,t; for(int i=0; i<m; i++) { scanf("%lld",&k); if(k==1) { scanf("%lld%lld%lld",&x,&y,&t); if(t==1)continue; else { for(x; x<=y; x++) { if(num[x]>=t&&num[x]%t==0) { //cout<<"++"<<endl; add(x,num[x]/t-num[x]); num[x]/=t; } } } } else if(k==2) { scanf("%lld%lld",&x,&y); printf("%lld\n",sum(y)-sum(x-1)); } }}
阅读全文
0 0
- CCF 除法
- ccf 除法
- CCF NOI1040 除法游戏
- CCF 201709-5 除法
- 201709-5 除法 ccf
- ccf 201709-5 除法
- CCF认证2017-9 除法
- CCF 201709-5 除法 Java
- CCF考试——201709-5除法
- [ACM]CCF CSP [201709-5]E题 除法
- 除法
- 除法
- 除法
- 除法
- 除法
- 除法
- 除法
- 除法
- 杭code1008
- 7.1 分析并写出下面程序的运行结果
- Python安装
- 理解java的三大特性之多态
- struts.xml配置文件中自动提示配置
- ccf 除法
- 线程同步
- Cash Machine --多重背包
- 判断蓝牙打开关闭状态+wifi打开关闭状态
- 3
- Dl4j-fit(DataSetIterator iterator)源码阅读(二)
- 自定义View绘制五星红旗
- linux sed命令用法举例
- LeetCode 135. Candy