Codeforces 616E Sum Of Reminders
来源:互联网 发布:手机淘宝货到付款骗局 编辑:程序博客网 时间:2024/06/04 01:11
616传送门:http://codeforces.com/contest/616/problem/E
刚开始那个判断条件写错了,即判断什么时候应该减掉,减的方法对了,但刚开始写的那个条件是永远都成立的,if(ans[i-1].fi<m)这样就导致了第一个样例总是多减掉,而实际应该是当m<n的时候减掉,这就说明自己想的时候是只按照那一种情况想的,应该跳出思维的局限性写的时候卡了2处:第一处为存因子的时候,由于对具体的过程没有想清楚,所以在*号里面的存储方式是错误的比方说:251 252 123 84 65 56 48 312 2只有在根号N后面的才可以整体处理,而前面的则不行,因为越过根号N之后才能使后面的值保持不变,只有前面的基数足够大,才能使后面的商的结果不变,而只用因子那绝对是错的,下次应该在纸上模拟清楚之后再敲! ! !第二处错误为每一步都要取一次模,实际操作的过程中在局部乘法的时候忘记取模了,导致最后出现了负值(一次加法不足以加到正数),还有坑点就是在整除2的位置处要判断哪一个是正好整除,一定要细致! ! !**#include<bits/stdc++.h>using namespace std;#define ll long long#define pb push_back#define mp make_pair#define fi first#define se secondconst int maxn=1e3+10;ll n,m;const ll mod=1e9+7;vector<pair<ll,ll>>ans;void debug(){ for(pair<ll,ll> x:ans){ printf("%lld %lld\n",x.first,x.second); }}ll work(ll i,ll j){ if((i+j)%2==0) return (((i+j)/2%mod)*((j-i+1)%mod))%mod; return (((i+j)%mod)*((j-i+1)/2%mod))%mod;}int main(){ cin>>n>>m; ll sum=((n%mod)*(m%mod))%mod; for(ll i=1;i*i<=n;i++){ ll tmp=n/i; ans.pb(mp(i,tmp)); if(tmp!=i) ans.pb(mp(tmp,i)); /*if(n%i==0){ ans.pb(mp(i,n/i)); } if(n!=i*i) ans.pb(mp(n/i,i));*/ } ans.pb(mp(0,0)); sort(ans.begin(),ans.end()); //debug(); int i; for(i=1;i<ans.size()&&ans[i].fi<=m;i++){ sum=(sum-((work(ans[i-1].fi+1,ans[i].fi)*(ans[i].se%mod)))%mod+mod)%mod; } if(m<n){ i--; sum=(sum-((work(ans[i].fi+1,m)*(ans[i+1].se%mod)))%mod+mod)%mod; } cout<<sum<<endl; return 0;}
0 0
- Codeforces 616E Sum Of Reminders
- Codeforces 616E Sum of Remainders
- codeforces 616E - Sum of Remainders
- Codeforces 616E - Sum of Remainders
- 【数论】【分块】【乱搞】codeforces 616E Sum of Remainders
- Codeforces 616E Sum of Remainders 【数学分块】
- CodeForces 616E Sum of Remainders(数论)
- codeforces 616E Sum of Remainders 数学公式转化
- codeforces 616E Sum of Remainders(数学公式转化 较难)
- CodeForces - 616E Sum of Remainders (数论)大数取余求和 好题
- Educational Codeforces Round 5 E. Sum of Remainders 数论
- Educational Codeforces Round 5 E. Sum of Remainders(数学)
- Codeforces educational round 5. E Sum of Remainders 数论 分块
- Educational Codeforces Round 5 E. Sum of Remainders
- Educational Codeforces Round 5-E. Sum of Remainders
- Codeforces 631E:Product Sum
- Educational Codeforces Round 5 E. Sum of Remainders 思维 数学转换
- Codeforces E. Field of Wonders
- android apk 防止反编译技术第二篇-运行时修改Dalvik指令
- 最近5年133个Java面试问题列表
- node与ES6系列3——generator对象
- android混淆去掉日志
- 从编译到制作固件
- Codeforces 616E Sum Of Reminders
- iOS应用生命周期相关内容
- node与ES6系列4——class
- jdk配置正确但是tomcat服务器启动时一闪而过
- 从Java回调机制分析Android动态加载布局过程中出现的IllgalStateException
- socat的安装与使用
- What happens when you run a container?
- 安卓程序运行中突然崩溃的时候打印日志到本地
- windows DLL动态连接库文件的实现和应用