zoukankan      html  css  js  c++  java
  • CD from Codeforces Round #701 (Div. 2)

    C. Floor and Mod

    (⌊ab⌋=a \% b=k),易推导得:若(x)满足条件,则(x=kb+k)。直接去枚举(k),去构造(b)能取值的区间(lb)(rb)(ans+=rb-lb+1)

    先构造左区间的(lb=k+1),假设左区间合法;去构造右区间的(rb=b/k-1),然后check左右区间是否满足(lb<=rb),如果满足则计入答案,否则直接(break)

    #include<bits/stdc++.h>
    using namespace std;
    #define ll long long
    #define ull unsigned long long
    #define pll pair<ll,ll>
    #define pii pair<int,int>
    #define vll vector<ll>
    #define vpll vector<pll>
    #define fastio ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
    double pi = acos(-1);
    const double eps = 1e-9;
    const int inf = 1e9 + 7;
    const ll lnf = 1e18 + 7;
    const int maxn = 1e5 + 10;
    ll mod = 1e9 + 7;
    
    int main()
    {
    	fastio;
    	int t;
    	cin >> t;
    	while (t--)
    	{
    		ll a, b;
    		cin >> a >> b;
    		b = min(a, b);
    		ll ans = 0;
    		for (ll k = 1; k < b; k++)//目的是构造b
    		{
    			ll lb = k + 1, rb = a / k - 1;
    			//左区间的b,右区间的b
    			if (k > rb)break;
    			rb = min(rb, b);
    			ans += rb - lb + 1;
    		}
    		cout << ans << endl;
    	}
    
    	return 0;
    
    }
    
    

    D. Multiples and Power Differences

    (720720 = 2 * 2 * 2 * 2 * 3 * 3 * 5 * 7 * 11 * 13 = lcm(1,2,...,16)) ,这样所有数的四次方与(720720)做差都是1 到 16的倍数。

    ((i+j)\%2=0)的块为(720720),其余为(720720-x^4)

    #include<bits/stdc++.h>
    using namespace std;
    #define ll long long
    #define ull unsigned long long
    #define pll pair<ll,ll>
    #define pii pair<int,int>
    #define vll vector<ll>
    #define fastio ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
    double pi = acos(-1);
    const double eps = 1e-9;
    const int inf = 1e9 + 7;
    const ll lnf = 1e18 + 7;
    const int maxn = 2e5 + 10;
    ll mod = 1e9 + 7;
    
    int main()
    {
    	fastio;
    	//cout << 2 * 2 * 2 * 2 * 3 * 3 * 5 * 7 * 11 * 13 << endl;
    	int n, m;
    	cin >> n >> m;
    	for (int i = 1; i <= n; i++)
    	{
    		for (int j = 1; j <= m; j++)
    		{
    			int x;
    			cin >> x;
    			if ((i + j) & 1)
    				cout << 720720 - x*x*x*x << " ";
    			else cout << 720720<<" ";
    		}
    		cout << endl;
    	}
     
    	return 0;
     
    }
    
  • 相关阅读:
    Python 面向对象(下)
    Python 面向对象(上)
    《面向对象程序设计概述》 牛咏梅
    lastIndexOf is not a function
    oracle lpad 函数使用介绍
    oracle中length、lengthb、substr、substrb用法小结
    oracle获取字符串长度函数length()和hengthb()
    js获取当前日期时间
    win7系统下查看端口的占用情况以及如何删除端口进程
    IntelliJ IDEA “Finds duplicated code”提示如何关闭
  • 原文地址:https://www.cnblogs.com/ruanbaiQAQ/p/14430089.html
Copyright © 2011-2022 走看看