暂存
来源:互联网 发布:国外开源cms 编辑:程序博客网 时间:2024/04/28 02:53
约瑟夫环
#include <bits/stdc++.h>using namespace std;const int N = 1000 + 10;int main(){ int n, k; scanf("%d%d", &n, &k); int ans = 0; for(int i = 2; i <= n; i++) ans = (ans + k) % i; printf("%d\n", ans + 1); return 0;}
染色
bool dfs(int v, int x){ color[v] = x; for(int i = head[v]; ~i; i = g[i].next) { int u = g[i].to; if(color[v] == color[u]) return false; if(! color[u] && !dfs(u, -color[v])) return false; } return true;}bool bfs(int v, int x){ queue<int> que; que.push(v), color[v] = x; while(! que.empty()) { int v = que.front(); que.pop(); for(int i = head[v]; ~i; i = g[i].next) { int u = g[i].to; if(color[v] == color[u]) return false; if(! color[u]) color[u] = -color[v], que.push(u); } } return true;}
自造随机数(不会重复)
inline int random(){ static int seed=703; //seed可以随便取 return seed=int(seed*48271LL%2147483647);}
阅读全文
0 0
- 暂存
- 暂存
- 暂存
- 暂存
- 暂存
- 暂存
- 暂存
- 暂存
- 暂存
- 暂存
- 暂存
- 暂存
- 暂存
- 暂存
- 暂存资料
- 暂存链接
- List(暂存)
- 暂存资源
- boost之asio同步io使用实例
- C++面试题(十四). 腾讯 & 斐讯 & 网宿 & TP-LINK
- IDA decompilation failure
- Android阿里云推送
- 设计模式之享元模式(4)
- 暂存
- JAVA提高篇(31)--Iterator和ListIterator 迭代器的使用(遍历集合)
- boost之asio异步io使用实例
- 剑指Offer题目1520:树的子结构
- 使用TinyProxy搭建代理服务器
- 基于 JDK 8 time包的时间工具类
- qt5配置sp++
- 自定义控件触动事件
- 【LeetCode算法练习(C++)】3Sum