Codeforces Round #701 (Div. 2) C. Floor and Mod codeforces 思维 + 数学

701C
在这里插入图片描述

input

9
3 4
2 100
4 3
50 3
12 4
69 420
12345 6789
123456 789
12345678 9

output

1
0
2
3
5
141
53384
160909
36

solution

假 设 x / y = x % y = a 假设x/y=x\%y=a x/y=x%y=a

按 照 a = 1 开 始 枚 举 , a = i 时 按照a=1开始枚举,a=i时 a=1a=i
最 小 的 符 合 次 情 况 的 点 对 为 ( i ∗ ( i + 2 ) , i + 1 ) 最小的符合次情况的点对为(i*(i+2),i+1) (i(i+2),i+1)
因 此 符 合 的 点 对 为 ( i ∗ ( i + 2 ) + i ∗ t , i + 1 + t ) , t ∈ Z + , r e s + = t 详 情 见 代 码 因此符合的点对为(i*(i+2)+i*t,i+1+t),t∈Z_+,res+=t详情见代码 (i(i+2)+it,i+1+t)tZ+res+=t

code

    //Siberian Squirrel
    //#include<bits/stdc++.h>
    //#include<unordered_map>
    #include<algorithm>
    #include<iostream>
    #include<cstring>
    #include<cmath>
     
    //#define ACM_LOCAL
     
    using namespace std;
    typedef long long ll;
     
    const double PI = acos(-1);
    const double eps = 1e-7;
    const int MOD = 3221225473;
    const int N = 5e6 + 10;
    const int UP = 1e4;
     
    inline ll solve(int x, int y, ll res = 0) {
    //    res += min(x, y - 1);
    	for(int i = 1; ; ++ i) {
    		int temp = i * (i + 2), _temp = i + 1;
    		if(temp > x || _temp > y) break;
    		res += min((x - temp) / i + 1, y - i);
    	}
    	return res;
    }
     
    int main() {
    #ifdef ACM_LOCAL
        freopen("input", "r", stdin);
        freopen("output", "w", stdout);
    #endif
        int o = 1, n, m, x, y;
        scanf("%d", &o);
        while(o --) {
            scanf("%d%d", &x, &y);
            printf("%lld\n", solve(x, y));
        }
        return 0;
    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值