[51NOD]2 3 5 7鐨勫€嶆暟锛堝鏂ュ師鐞嗭級

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[51NOD]2 3 5 7鐨勫€嶆暟锛堝鏂ュ師鐞嗭級相关的知识,希望对你有一定的参考价值。

鏍囩锛?/p>

棰樼洰閾炬帴锛歨ttp://www.51nod.com/onlineJudge/questionCode.html#!problemId=1284

浼间箮鏈€杩戞病鎬庝箞鍋氬鏂ュ師鐞嗗晩锛屾潵澶嶄範涓€鍙戞蹇点€?/p>

瀹规枼鍘熺悊鍏紡锛?img alt="鎶€鏈垎浜? style="line-height: 1.5;" src="http://image.mamicode.com/info/201609/20180110210112209486.png" />

涓€鑸仛娉曢兘鏄厛鎼炰竴涓紡瀛愬嚭鏉ワ紝鍐嶆灇涓炬墍鏈夊瓙闆嗭紝鐢ㄥ紡瀛愭潵纭畾绗﹀彿鍜屽瓙闆嗙殑鍏崇郴銆傚皬瀛︾敓瀹规枼銆傘€?/p>

  1 /*
  2 鈹佲攣鈹佲攣鈹佲敀銈儶銈儶鈾?eye锛?
  3 鈹撯攺鈹撯攺鈹撯攦銈儶銈儶鈾?mind锛?
  4 鈹涒敆鈹涒敆鈹涒攦锛尖棆锛?
  5 鈹撯攺鈹撯攺鈹撯攦 /
  6 鈹涒敆鈹涒敆鈹涒攦銉?
  7 鈹撯攺鈹撯攺鈹撯攦
  8 鈹涒敆鈹涒敆鈹涒攦
  9 鈹撯攺鈹撯攺鈹撯攦
 10 鈹涒敆鈹涒敆鈹涒攦
 11 鈹撯攺鈹撯攺鈹撯攦
 12 鈹涒敆鈹涒敆鈹涒攦
 13 鈹撯攺鈹撯攺鈹撯攦
 14 鈹冣攦鈹冣攦鈹冣攦
 15 鈹烩敾鈹烩敾鈹烩敾
 16 */
 17 #include <algorithm>
 18 #include <iostream>
 19 #include <iomanip>
 20 #include <cstring>
 21 #include <climits>
 22 #include <complex>
 23 #include <fstream>
 24 #include <cassert>
 25 #include <cstdio>
 26 #include <bitset>
 27 #include <vector>
 28 #include <deque>
 29 #include <queue>
 30 #include <stack>
 31 #include <ctime>
 32 #include <set>
 33 #include <map>
 34 #include <cmath>
 35 using namespace std;
 36 #define fr first
 37 #define sc second
 38 #define cl clear
 39 #define BUG puts("here!!!")
 40 #define W(a) while(a--)
 41 #define pb(a) push_back(a)
 42 #define Rint(a) scanf("%d", &a)
 43 #define Rll(a) scanf("%I64d", &a)
 44 #define Rs(a) scanf("%s", a)
 45 #define Cin(a) cin >> a
 46 #define FRead() freopen("in", "r", stdin)
 47 #define FWrite() freopen("out", "w", stdout)
 48 #define Rep(i, len) for(int i = 0; i < (len); i++)
 49 #define For(i, a, len) for(int i = (a); i < (len); i++)
 50 #define Cls(a) memset((a), 0, sizeof(a))
 51 #define Clr(a, x) memset((a), (x), sizeof(a))
 52 #define Full(a) memset((a), 0x7f7f7f, sizeof(a))
 53 #define lrt rt << 1
 54 #define rrt rt << 1 | 1
 55 #define pi 3.14159265359
 56 #define RT return
 57 #define lowbit(x) x & (-x)
 58 #define onecnt(x) __builtin_popcount(x)
 59 typedef long long LL;
 60 typedef long double LD;
 61 typedef unsigned long long ULL;
 62 typedef pair<int, int> pii;
 63 typedef pair<string, int> psi;
 64 typedef pair<LL, LL> pll;
 65 typedef map<string, int> msi;
 66 typedef vector<int> vi;
 67 typedef vector<LL> vl;
 68 typedef vector<vl> vvl;
 69 typedef vector<bool> vb;
 70 
 71 LL ret;
 72 LL n;
 73 
 74 int main() {
 75     // FRead();
 76     while(cin >> n) {
 77         LL a,b,c,d,ab,ac,ad,bc,bd,cd,abc,abd,acd,bcd,abcd;
 78         a = n / 2;
 79         b = n / 3;
 80         c = n / 5;
 81         d = n / 7;
 82 
 83         ab = n / 6;
 84         ac = n / 10;
 85         ad = n / 14;
 86         bc = n / 15;
 87         bd = n / 21;
 88         cd = n / 35;
 89 
 90         abc = n / 30;
 91         abd = n / 42;
 92         acd = n / 70;
 93         bcd = n / 105;
 94 
 95         abcd = n / 210;
 96 
 97         cout << n-(a+b+c+d-ab-ac-ad-bc-bd-cd+abc+abd+acd+bcd-abcd) << endl;
 98     }
 99     RT 0;
100 }

 

以上是关于[51NOD]2 3 5 7鐨勫€嶆暟锛堝鏂ュ師鐞嗭級的主要内容,如果未能解决你的问题,请参考以下文章

51Nod 1248 2 3 5 7 的倍数 容斥

51-nod -1284 2 3 5 7的倍数

51Nod——N1284 2 3 5 7的倍数

51Nod 1284 2 3 5 7的倍数

51nod 1284 2 3 5 7的倍数

[51nod]1284 2 3 5 7的倍数