zoukankan      html  css  js  c++  java
  • Problem E Divisibility (11年珠海区域赛)

    题意:找出b进制中n = ak * bk + ak-1 * bk-1 + ... + a1 * b + a0 除进 x 当且仅当 ak + ... + a0 除进 x, 和 n 除进 y 当且仅当 (a0 + a2 + ...) - (a1 + a3 + ...) 除进 y.

    思路:x = 1(mod b) y = -1 (mod b)。想一下便知道了

    代码如下:

     1 /**************************************************
     2  * Author     : xiaohao Z
     3  * Blog     : http://www.cnblogs.com/shu-xiaohao/
     4  * Last modified : 2014-03-30 13:19
     5  * Filename     : main.cpp
     6  * Description     : 
     7  * ************************************************/
     8 
     9 #include <iostream>
    10 #include <cstdio>
    11 #include <cstring>
    12 #include <cstdlib>
    13 #include <cmath>
    14 #include <algorithm>
    15 #include <queue>
    16 #include <stack>
    17 #include <vector>
    18 #include <set>
    19 #include <map>
    20 #define MP(a, b) make_pair(a, b)
    21 #define PB(a) push_back(a)
    22 
    23 using namespace std;
    24 typedef long long ll;
    25 typedef pair<int, int> pii;
    26 typedef pair<unsigned int,unsigned int> puu;
    27 typedef pair<int, double> pid;
    28 typedef pair<ll, int> pli;
    29 typedef pair<int, ll> pil;
    30 
    31 const int INF = 0x3f3f3f3f;
    32 const double eps = 1E-6;
    33 const int LEN = 1010;
    34 
    35 int main()
    36 {
    37 //    freopen("in.txt", "r", stdin);
    38 
    39     int T;
    40     cin >> T;
    41     while(T--){
    42         int n;
    43         cin >> n;
    44         for(int i=2; i<n; i++){
    45             if(n%i == 1) {
    46                 cout << i;
    47                 break;
    48             }
    49         }
    50         for(int i=2; i<=n+1; i++){
    51             if(n%i == i-1) {
    52                 cout << " " << i << endl;
    53                 break;
    54             }
    55         }    
    56     }
    57     return 0;
    58 }
    View Code
  • 相关阅读:
    DOM-window下的常用子对象-location-刷新页面
    row_number over( partition by xx)
    linux openjdk安装
    ffmpeg直播系统
    flink 基本原理
    flink分层 api
    flink测试用例编写
    使用mybatis的动态sql解析能力生成sql
    大数据量显示问题
    vue使用日记
  • 原文地址:https://www.cnblogs.com/shu-xiaohao/p/3634398.html
Copyright © 2011-2022 走看看