• [zoj3629]找规律


    题意:a[n] = ([n/1] + [n/2] + ... + [n/n]) & 1 == false,找出a数组的规律来就ok了。

     1 #pragma comment(linker, "/STACK:10240000,10240000")
     2 
     3 #include <iostream>
     4 #include <cstdio>
     5 #include <algorithm>
     6 #include <cstdlib>
     7 #include <cstring>
     8 #include <map>
     9 #include <queue>
    10 #include <deque>
    11 #include <cmath>
    12 #include <vector>
    13 #include <ctime>
    14 #include <cctype>
    15 #include <set>
    16 
    17 using namespace std;
    18 
    19 #define mem0(a) memset(a, 0, sizeof(a))
    20 #define lson l, m, rt << 1
    21 #define rson m + 1, r, rt << 1 | 1
    22 #define define_m int m = (l + r) >> 1
    23 #define rep(a, b) for (int a = 0; a < b; a++)
    24 #define rrep(a, b) for (int a = (b - 1); a >= 0; a--)
    25 #define all(a) (a).begin(), (a).end()
    26 #define lowbit(x) ((x) & (-(x)))
    27 #define constructInt4(name, a, b, c, d) name(int a = 0, int b = 0, int c = 0, int d = 0): a(a), b(b), c(c), d(d) {}
    28 #define constructInt3(name, a, b, c) name(int a = 0, int b = 0, int c = 0): a(a), b(b), c(c) {}
    29 #define constructInt2(name, a, b) name(int a = 0, int b = 0): a(a), b(b) {}
    30 #define pc(a) putchar(a)
    31 #define ps(a) printf("%s", a)
    32 #define pd(a) printf("%d", a)
    33 #define sd(a) scanf("%d", &a)
    34 
    35 typedef double db;
    36 typedef long long LL;
    37 typedef unsigned long long uLL;
    38 typedef pair<int, int> pii;
    39 typedef multiset<int> msi;
    40 typedef set<int> si;
    41 typedef vector<int> vi;
    42 typedef map<int, int> mii;
    43 
    44 const int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
    45 const int dy[8] = {1, 0, -1, 0, -1, 1, 1, -1};
    46 const int maxn = 5 * 1e4 + 7;
    47 const int maxm = 1e5 + 7;
    48 const int minv = 1e7 + 7;
    49 const int max_val = 1e6 + 7;
    50 const int MD = 1e9 +7;
    51 const LL INF = 1e15;
    52 const double PI = acos(-1.0);
    53 const double eps = 1e-10;
    54 
    55 template<class T> T gcd(T a, T b) { return b == 0? a : gcd(b, a % b); }
    56 
    57 uLL a, b;
    58 
    59 uLL g(LL n) { return n * (2 * n - 1); }
    60 
    61 uLL f(uLL x) {
    62     uLL l = 1, r = 0xFFFFFFFF;
    63     while (l < r) {
    64         uLL m = (l + r) >> 1;
    65         if (m * m < x) l = m + 1;
    66         else r = m;
    67     }
    68     uLL n = l, rest = x - (n - 1) * (n - 1), ans = 0;
    69     if (n & 1) ans += rest;
    70     ans += g(n >> 1);
    71     return ans;
    72 }
    73 
    74 int main() {
    75     //freopen("in.txt", "r", stdin);
    76     while (cin >> a >> b) {
    77         a++; b++;
    78         cout << f(b) - f(a - 1) << endl;
    79     }
    80     return 0;
    81 }
    View Code
  • 相关阅读:
    光脚丫学LINQ(025):如何验证DBML和外部映射文件
    使用LINQ to SQL将数据从一个数据库复制到另一个数据库
    用VS2010 C#写DLL文件并且调用(原创)
    linux初识
    Run Only One Copy Of Application
    SQL Server 2008开启远程连接
    用Visual C#做DLL文件
    SQL Server代理服务无法启动的处理方法(转载)
    QTP连接Oracle
    What's AJAX?
  • 原文地址:https://www.cnblogs.com/jklongint/p/4419003.html
Copyright © 2020-2023  润新知