1199

Aaron_wch

L-China

ash_heat

୧暖冬依旧以成爱

ssy_

Richard_H
ls-408
yoakashi

#include <iostream>
#include <cstdio>

using namespace std;

int x;

int main()
{
cin>>x;
int u = 0;
if(x % 5)  u = 1;
cout<<x / 5 + u <<endl;
}


#include <iostream>
#include <cstring>

using namespace std;

int n;
int res;

int main()
{
cin>>n;

while(n -- )
{
int x ;
scanf("%d", &x);
res = res ^ x;
}

if(res == 0) puts("No");

else puts("Yes");

return 0;
}


#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cmath>

using namespace std;

typedef long long LL;

const int N = 1000010;

int prime[N];
bool st[N];
int n , cnt;

void init()
{
for(int i = 2; i <= N; i ++)
{
if(!st[i])  prime[++cnt] = i;

for(int j = 1; (LL)1 * prime[j] * i <= N; j ++)
{
st[prime[j] * i] = true;
if(i % prime[j] == 0)  break;
}
}
}

int main()
{
cin>>n;
init();
st[1] = true;
while(n --)
{
LL x;
scanf("%lld", &x);

int t = sqrt(x);
if(!st[t] && (LL)1 * t * t == x)  puts("YES");
else puts("NO");
}

return 0;
}


//priority_queue<int ,vector<int>,greater<int> >q;  stl容器里面小根堆的初始化方式
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>

#define x first
#define y second

using namespace std;

typedef pair<int, int> PII;
const int N = 1000010, INF = 0x3f3f3f3f;

int n, m;
int h[N], w[N], ne[N], idx, e[N];
int dist[N];
bool st[N];

void add(int a, int b, int c)
{
e[idx] = b;
w[idx] = c;
ne[idx] = h[a];
h[a] = idx ++;
}

int dijkstra()
{
memset(dist, 0x3f, sizeof dist);
dist[1] = 0;
priority_queue<PII, vector<PII>, greater<PII>> heap;
heap.push({0, 1});

while (heap.size())
{
auto t = heap.top();
heap.pop();

int ver = t.second, distance = t.first;

if (st[ver]) continue;
st[ver] = true;

for (int i = h[ver]; i != -1; i = ne[i])
{
int j = e[i];
if (dist[j] > dist[ver] + w[i])
{
dist[j] = dist[ver] + w[i];
heap.push({dist[j], j});
}
}
}

if (dist[n] == 0x3f3f3f3f) return -1;
return dist[n];
}

int main()
{
scanf("%d%d", &n, &m);

memset(h, -1, sizeof h);
while (m -- )
{
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
add(a, b, c);
}

printf("%d\n", dijkstra());

return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
const int N = 100010;
int idx=1,head, e[N], ne[N];

//初始化
void init()
{
head = -1;
idx = 1;
}
//在头结点增加节点
void add_head(int x)
{
e[idx] = x, ne[idx] = head, head = idx ++ ;
}
//压栈
void push(int u)
{
add_head(u);
}
//弹栈
void pop()
{
head = ne[head];
}
//判断是否为空
bool empty()
{
if(head == -1)  return true;
else return false;
}
//获取栈顶元素
int ftop()
{
return e[head];
}

int main()
{
init();
int n;
cin >> n;
while(n--)
{
string s;
cin >> s;

if(s == "push")
{
int a;
cin >> a;
push(a);
}

if(s == "pop")
{
pop();
}

if(s == "query")
{
cout << ftop() << endl;
}

if(s == "empty")
{
if(empty()) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
}
}


#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

const int N = 100010;

int a[N];//保存数组
int n, m;//n个点，求前m小
int r ;//堆得右边界
void down(int u)//调整函数
{
//t记录最小点的编号
int t = u;

//有左儿子，并且左儿子比t节点的值小，更新t
if(2 * u <= r && a[2 * u] < a[t]) t = 2 * u;

//有右儿子，并且右儿子比t节点的值小，更新t
if(2 * u + 1 <= r && a[2 * u + 1] < a[t]) t = 2 * u + 1;

//如果待调整点不是最小的
if(u != t)
{
//和最小的交换
swap(a[u], a[t]);

//递归处理
down(t);
}
}

int main()
{
cin >> n >> m;
r = n;//开始时，右边界是数组边界

//读入数据
for (int i = 1; i <= n; i ++ )
{
int x;
cin >> a[i];
}

//从第一个非叶节点开始，从右到左，从下到上处理每个节点
for(int i = n /2 ; i >= 1; i--)
{
down(i);
}

//输出m个最小值
while (m -- )
{
//堆顶保存的最小值，输出堆顶
cout << a[1] << " ";

//将堆顶和右边界交换
swap(a[1], a[r]);

//右边界左移
r--;

//从新处理堆顶
down(1);
}
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
const int N = 510,INF = 0x3f3f3f3f;
int g[N][N];
int dist[N];
bool st[N];
int n, m;

int dijkstra()
{
memset(dist, INF, sizeof dist);
dist[1] = 0;

for (int i = 0; i < n - 1; i ++ )
{
int t = -1;
for (int j = 1; j <= n; j ++ )
if (!st[j] && (t == -1 || dist[t] > dist[j]))
t = j;

for (int j = 1; j <= n; j ++ )
dist[j] = min(dist[j], dist[t] + g[t][j]);

st[t] = true;
}

if (dist[n] == 0x3f3f3f3f) return -1;
return dist[n];
}

int main()
{
cin>>n>>m;
memset(g,INF,sizeof g);
while(m --)
{
int a,b,c;
scanf("%d%d%d", &a,&b,&c);
g[a][b] = min(g[a][b],c);
}

cout<<dijkstra()<<endl;

return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
const int N = 1010, M = 100010;
int idx,h[N],e[M], ne[M];
int n,l;
int cnt;
int x;
bool st[N];

void add(int a,int b)
{
ne[idx] = h[a];
e[idx] = b;
h[a] = idx ++;
}

int bfs(int start)
{
queue<int> q;
memset(st,0,sizeof st);
q.push(start);
st[start] = true;
int res = 0;

for(int i=0;i<l;i++)
{
int sz = q.size();
while(sz --)
{
int t = q.front();
q.pop();
for(int j=h[t];j != -1;j=ne[j])
{
int u = e[j];
if(!st[u])
{
q.push(u);
st[u] = true;
res ++;
}
}
}
}

return res;
}

int main()
{
cin>>n>>l;
memset(h,-1,sizeof h);
for(int i=1;i<=n;i++)
{
scanf("%d",&cnt);
while(cnt --)
{
scanf("%d",&x);
add(x,i);
}
}

int k;
cin>>k;
while(k --)
{
scanf("%d",&x);
cout<<bfs(x)<<endl;
}

return 0;
}


#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
using namespace std;
const int N = 100010;
int a[N];
int s[N];
int n;
int res = 1;

int main()
{
cin>>n;
for(int i=0;i<n;i++)  scanf("%d",&a[i]);

for(int i=0,j=0;i<n;i++)
{
s[a[i]] ++;
while(s[a[i]]>1)
{
s[a[j]]--;
j++;
}
res = max(res,i - j + 1);
}

cout<<res<<endl;
return 0;
}