A:水

B:求两个三角形之间的位置关系:相交 相离 内含

①用三个点是否在三角形内外判断    计算MA*MB、MB*MC、MC*MA的大小 若这三个值同号,那么在三角形的内部,异号在外部

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#define INF 2139062143
#define inf -2139062144
#define ll long long
using namespace std;
int x[],y[];
int dian(int a,int i,int j) {
return (x[a] - x[i])*(x[a]-x[j]) + (y[a] - y[i]) * (y[a] - y[j]);
}
bool pan(int a,int b,int c) {
int zheng = ,fu = ;
if(a>) zheng++;
if(b>) zheng++;
if(c>) zheng++;
fu = - zheng;
if(fu == || fu == ) return true;
else return false;
}
int main() {
int t;
int i;
scanf("%d",&t);
bool xx[];
while(t--) {
for(i=; i<; i++) {
scanf("%d%d",&x[i],&y[i]);
}
for(i=; i<; i++) {
xx[i] = pan(dian(i,,),dian(i,,),dian(i,,));
// printf("fuck:%d %d %d\n",dian(i,3,4),dian(i,4,5),dian(i,3,5));
}
for(i=; i<; i++) {
xx[i] = pan(dian(i,,),dian(i,,),dian(i,,));
// printf("fuck:%d %d %d\n",dian(i,0,1),dian(i,0,2),dian(i,1,2));
}
// for(i=0; i<6; i++) printf("%d ",xx[i]);
if(xx[] == true && xx[] == true && xx[] == true) {
printf("contain\n");
continue;
}
if(xx[] == true && xx[] == true && xx[] == true) {
printf("contain\n");
continue;
}
if(xx[] == false && xx[] == false && xx[] == false && xx[] == false && xx[] == false && xx[] == false) {
printf("disjoint\n");
continue;
}
printf("intersect\n");
}
return ;
}

D:KMP加上特殊情况判断

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#define INF 2139062143
#define inf -2139062144
#define MOD 1000000007
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define pai pair<int,int>
using namespace std;
string ori,pat;
int n,nxt[],ans=;
int GetNext()
{
nxt[]=nxt[]=;
for(int i=;i<pat.size();i++)
{
int j=nxt[i];
while(j&&pat[i]!=pat[j])j=nxt[j];
nxt[i+]=((pat[i]==pat[j])?j+:);
}
}
int Kmp()
{
memset(nxt,,sizeof(nxt));
GetNext();
int j=;
for(int i=;i<ori.size();i++)
{
while(j&&ori[i]!=pat[j])j=nxt[j];
if(ori[i]==pat[j])j++;
if(j==pat.size())ans++;
}
}
int main()
{
scanf("%d",&n);
for(int i=;i<=n;i++)
{
cin>>ori>>pat;
if(pat.size()>ori.size())
{
cout<<"Bob"<<endl;
}else
{
int flag1=,flag2=;
ans=;Kmp();
if(ans)flag1=;
reverse(pat.begin(),pat.end());
string t="";
int j;
for(j=;j<pat.size();j++)
{
if(pat[j]!='')break;
}
for(;j<pat.size();j++)
{
t+=pat[j];
}
pat=t;
ans=;Kmp();
if(ans)flag2=;
if(flag1||flag2)cout<<"Alice"<<endl;else cout<<"Bob"<<endl;
}
}
return ;
}

G:猜公式(JAVA)

import java.math.BigInteger;
import java.util.Scanner; public class Main { public static void main(String[] args) {
int t;
Scanner input = new Scanner(System.in);
t = input.nextInt();
while (t-- > ) {
// BigInteger n = input.nextBigInteger();
int n = input.nextInt();
BigInteger flag = BigInteger.valueOf();
for(int i = ;i<=n;i++){
flag = flag.multiply(BigInteger.valueOf(i));
}
BigInteger ans = BigInteger.valueOf();
for(int i = ;i<=n;i++){
ans = ans.add(flag.divide(BigInteger.valueOf(i)));
}
System.out.println(ans + ".0");
}
}
}

F:DFS序加树状数组  子节点增加的值为x+dep[v]∗k−dep[s]∗k,那么维护两个值x+dep[v]*k与-k,用两个树状数组维护这两个值,做到区间修改,单点查询

I:哈希加暴力 或者直接用strcmp函数判

K:错排加逆元加快速幂

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#define INF 2139062143
#define inf -2139062144
#define MOD 1000000007
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define pai pair<int,int>
//using ll = long long;
//using ull= unsigned long long;
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pai1;
const double EPS=1e-;
const double PI=acos(-);
ll mod=;
const int maxn=;
ll cuo[maxn];
ll ni[maxn];
ll jie[maxn];
ll quick_pow(ll a,ll n)
{
ll result=;
while(n>)
{
if(n&)
result=(result*a)%mod;
a=(a*a)%mod;
n/=;
}
return result;
}
void init()
{
cuo[]=;
cuo[]=;
for(int i=;i<=;i++)
cuo[i]=(i-)*(cuo[i-]+cuo[i-])%mod;
ni[]=jie[]=;
jie[]=ni[]=ni[]=jie[]=;
for(int i=;i<=;i++)
{
jie[i]=i*jie[i-]%mod;
ni[i]=quick_pow(jie[i],mod-);
}
}
int main()
{
//freopen("input.txt","r",stdin);
//freopen("out.txt","w",stdout);
init();
int t;
cin>>t ;
ll anser=;
while(t--)
{
anser=;
int n,k;
cin >> n >> k;
int now=n-k;
if(now==||now==)
{
if(now==)
{
printf("1\n");
continue;
}
else
{
printf("0\n");
continue;
}
}
anser++;
ll cur=;
for(int i=now;i>=;i--)
{
anser+=(((jie[n]*ni[i]%mod)*ni[n-i]%mod)*cuo[i])%mod;
}
cout<<anser%mod<<endl;
}
return ;
}

L:爆搜

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#define INF 2139062143
#define inf -2139062144
#define ll long long
using namespace std;
int qi[][];
bool flag;
int ini;
bool pan(int des) {
if(qi[][] == qi[][] && qi[][] == qi[][] && qi[][] == des) return true;
if(qi[][] == qi[][] && qi[][] == qi[][] && qi[][] == des) return true;
if(qi[][] == qi[][] && qi[][] == qi[][] && qi[][] == des) return true; if(qi[][] == qi[][] && qi[][] == qi[][] && qi[][] == des) return true;
if(qi[][] == qi[][] && qi[][] == qi[][] && qi[][] == des) return true;
if(qi[][] == qi[][] && qi[][] == qi[][] && qi[][] == des) return true; if(qi[][] == qi[][] && qi[][] == qi[][] && qi[][] == des) return true;
if(qi[][] == qi[][] && qi[][] == qi[][] && qi[][] == des) return true;
return false;
}
bool dfs(int now,int step) {
int i,j;
if(step == ) {
if(pan(ini)) flag = true;
for(i=; i<; i++) {
for(j=; j<; j++) {
// printf("fuck:%d %d %d\n",i,j,qi[i][j]);
if(qi[i][j] == ) {
qi[i][j] = ini;
if(pan(ini) == true) flag = true;
if(dfs(now * (-),) == true) flag = true;
qi[i][j] = ;
}
}
}
} else {
if(step == ) {
bool temp = true;
for(i=; i<; i++) {
for(j=; j<; j++) {
if(qi[i][j] == ) {
qi[i][j] = (ini*-);
if(pan(ini*-)) temp = false;
if(dfs(ini,) == false) temp = false;
qi[i][j] = ;
}
}
}
return temp;
} else {
if(step == ) {
bool tt = false;
for(i=; i<; i++) {
for(j=; j<; j++) {
if(qi[i][j] == ) {
qi[i][j] = ini;
if(pan(ini)) tt = true;
qi[i][j] = ;
}
}
}
return tt;
}
}
}
}
int main() {
int t;
scanf("%d",&t);
while(t--) {
int i,j;
getchar();
for(i=; i<; i++) {
for(j=; j<; j++) {
char x[];
scanf("%s",x);
char te = x[];
if(te == '.') qi[i][j] = ;
if(te == 'o') qi[i][j] = ;
if(te == 'x') qi[i][j] = -;
}
} char x[];
scanf("%s",x);
char te = x[];
int now;
if(te == 'o') now = ;
if(te == 'x') now = -;
ini = now;
flag = false; if(pan(ini * -) == true) {
printf("Cannot win!\n");
} else {
// for(i=0; i<3; i++) {
// for(j=0; j<3; j++)
// printf("%d ",qi[i][j]);
// printf("\n");
// }
dfs(now,);
if(flag) printf("Kim win!\n");
else printf("Cannot win!\n");
}
}
return ;
}

Summer training round2 #1的更多相关文章

  1. Summer training round2 #3

    A!:                    GTY系列题 B!:莫队加分块  GTY系列题 C!:线段树模拟拓扑排序(把普通的拓扑排序的栈操作改成线段树区间减一,查询区间最右侧的0的位置即可.注意一 ...

  2. Summer training round2 #8(Training26)

    A:贪心DFS 先从最远的搜起 如果一个点的value>=2 就ans++ D:并查集 E:大模拟 F:快速幂 #include <bits/stdc++.h> using name ...

  3. Summer training round2 #9(Training28)

    A:签到题 C:模拟搜索题 #include <bits/stdc++.h> #include <cstring> #include <iostream> #inc ...

  4. Summer training round2 #10(Training 30)

    A:签到题 B!:搜索+DP #include<bits/stdc++.h> #define mp make_pair #define pi pair<int,int> usi ...

  5. Summer training round2 #7 (Training #23)

    A:约瑟夫环 套公式 B:线性筛素数 C:投骰子 概率DP F:有权无向图的生成树(边最大值和最小值只差最小) 直接kruskal G:状压BFS或者双向BFS H:模拟题 I:几何题 J:高斯消元

  6. Summer training round2 #6 (Training #22)

    A:二分答案 如果中位数比目前的大就right=mid-1 else left=mid+1 C!:几何 G:优先队列贪心 #include <bits/stdc++.h> using na ...

  7. Summer training round2 #5 (Training #21)

    A:正着DFS一次处理出每个节点有多少个优先级比他低的(包括自己)作为值v[i] 求A B 再反着DFS求优先级比自己高的求C #include <bits/stdc++.h> #incl ...

  8. Summer training round2 #4 (Training #20)

    A!:UESTC1752 B!:找区间内L到R之间内的数的个数  权值分块加莫队 C!:给你一个哈斯图 去掉其中的几条边 要求输出字典序最大的拓扑排序:线段树模拟拓扑排序 D!:要求你找到最短路树并输 ...

  9. hdu 4946 2014 Multi-University Training Contest 8

    Area of Mushroom Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) ...

随机推荐

  1. Python的Multiprocessing多进程实例

    最近在拜读RBG大神的faster-rcnn源码时发现他用了多进程去分阶段处理神经网络,原因如下: # ------------------------------------------------ ...

  2. SqlServer数据库查看被锁表以及解锁Kill杀死进程

    步骤1.查看锁表进程        2.杀死进程 --1.查询锁表进程 spid.和被锁表名称 tableName select request_session_id spid,OBJECT_NAME ...

  3. “vmware 未能初始化监视器设备”的解决方法

    从挂起状态唤醒时出现"vmware 未能初始化监视器设备"的提示,在cmd中输入命令 net start vmci net start vmx86 可能还不能成功启动,提示&quo ...

  4. rpm操作

    --查找某个软件:abc rpm -qa |grep abc --删除某个软件:abc rpm -e --noscripts  abc

  5. 服务器iptables规则记录

    很多时候,我在我自己的VPS上面部署了Cobalt Strike,可是网上很多叼毛就会扫描我们的VPS,然后发现我们的Cobalt Strike,如果你还建有web delivery,还会被人家下载上 ...

  6. C++学习笔记-new与delete

    C++新增了new和delete关键字,用来开辟内存,对应的就是C语言的malloc和free 对比new/delete和malloc/free malloc和free是库函数,以字节为单位申请堆内存 ...

  7. 将对象以json格式写入到文件中

    将 list 对象以json格式写入到文件中 try { ObjectMapper mapper = new ObjectMapper(); String value = mapper.writeVa ...

  8. mybatis 基础(二) 动态sql 关于where if / where choose when otherwise

    个人理解: where if就相当于正常的java中的if 语句,如果有多个条件组合判断的话用 and, or连接 而where choose when otherwise choose就好像是swi ...

  9. leecode刷题(27)-- 合并k个排序链表

    leecode刷题(27)-- 合并k个排序链表 合并k个排序链表 合并 k 个排序链表,返回合并后的排序链表.请分析和描述算法的复杂度. 示例: 输入: [ 1->4->5, 1-> ...

  10. 基于EPICS实现西门子S7通信

    (1)       EPICS官网下载Demo并复制文件到指定位置 (2)       创建Modules文件夹,wget https://epics.anl.gov/download/modules ...