摘要:
int gcd(int a,int b) { return b == 0? a : gcd(b,a%b); } //返回最大公约数 //ax+by=gcd(a,b),求x,y int exgcd(int a,int b,int &x,int &y) { int d = a; if(b != 0) { 阅读全文
摘要:
#define P pair<int,int> int d[maxn]; int d2[maxn]; int SSC() { priority_queue<P,vector<P>,greater<P>> q; memset(d,INF,sizeof(d)); memset(d2,INF,sizeof 阅读全文
摘要:
int mincost[maxn]; bool used[maxn]; int MST() { _for(i,0,V) { mincost[i] = INF; used[i] = false; } mincost[0] = 0; int res = 0; while(1) { int v = -1; 阅读全文
摘要:
1 #define INF 0x3f3f3f3f 2 const int maxn = 503; 3 #define _for(i,a,b) for(int i = (a);i G[maxn]; 18 //from s to other V 19 void shortest_path(int s) 20 { 21 _for(... 阅读全文
摘要:
#include <bits/stdc++.h> #define pb push_back #define _for(i,a,b) for(int i = (a);i < (b);i ++) #define INF 0x3f3f3f3f using namespace std; const int 阅读全文
摘要:
1 #include 2 using namespace std; 3 4 #define pb push_back 5 #define maxSize 3939 6 #define _for(i,a,b) for(int i = (a);i list; 22 int num; 23 while(~scanf("%d",&num) && num!=0) 24 ... 阅读全文
摘要:
很典型的数位dp,把全球第一的代码拿过来研究了一下,加了点注释 代码作者:waakaaka 个人主页:https://leetcode.com/waakaaka/ 阅读全文
摘要:
1 class Solution 2 { 3 public: 4 int shipWithinDays(vector& weights, int D) 5 { 6 int load = 0; 7 for(int i = 0; i=0) 20 { 21 ... 阅读全文
摘要:
class Solution { public: int numPairsDivisibleBy60(vector& time) { int hash[1501] {0}; for(int i = 0;i =0&&left <= 1500) { ... 阅读全文
摘要:
1 #define _for(i,a,b) for(int i = (a);i < (b);i ++) 2 class Solution 3 { 4 public: 5 int bitwiseComplement(int N) 6 { 7 if(N==0) 8 return 1; 9... 阅读全文