90分..暂时没明白哪错了.....第一题题意:给你n个有序数,输出最大值,中位数,最小值。(如果有小数的话保留小数点后两位,整数的话不需要保留)
100分.....第二题题意:24点游戏,例如4+5+6+7 可以得出该值为22 不是24 故输出No
例1x2x6x2 该值为24 输出Yes 输入样例里的‘x’为称号 其余为运算符+ - /为加减除
4个数字在0-9之间
第二题的话,直接枚举出所有的可能性也是可以的吧......也可以用栈做
其他题.....没怎么懂
/*#include <iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
const LL N=2*1e7;
int main()
{
while(1){
LL n;
cin >> n;
LL a[n+5];
for(int i=0; i<n; i++){
cin >> a[i];
}
sort(a, a+n);
double t1 = a[n/2-1];
double t2 = a[n/2];
if(n%2){
cout << a[n-1] << " " << a[n/2] << " " << a[0] << endl;
}
else
// printf("%lld %.1f %lld", a[n-1], (t1+t2)/2, a[0]);
cout << a[n-1] << " " << (t1+t2)/2 << " " << a[0] << endl;//因为两位整数相加除二,有小数的话也就是0.5,故不考虑
}
return 0;
}
*/
#include <iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
//const LL N=2*1e7;
int main()
{
// while(1)
{
LL n, Min=0, Mid=0, Max=0, a;
cin >> n;
// LL a[n+5];
int flag = 0;
if(n%2){
flag = 1;
}
for(int i=0; i<n; i++){
cin >> a;
if(i == 0)
Min = a;
if(flag && i == n/2){
Mid = a;
}
if(i == n-1){
Max = a;
}
if(flag == 0){
if((i == n/2-1) || (i == n/2)){
Mid += a;
// cout << Mid << endl;
}
}
}
LL tmp;
if(Min > Max){
tmp = Min;
Min = Max;
Max = tmp;
}
if(n%2)
cout << Max << " " << Mid << " " << Min << endl;
else{
cout << Max << " " << (float)Mid/2.0 << " " << Min << endl;
}
}
/*
// sort(a, a+n);
//double t1 = a[n/2-1];
//double t2 = a[n/2];
if(n%2){
cout << a[n-1] << " " << a[n/2] << " " << a[0] << endl;
}
else
// printf("%lld %.1f %lld", a[n-1], (t1+t2)/2, a[0]);
cout << a[n-1] << " " << (t1+t2)/2 << " " << a[0] << endl;//因为两位整数相加除二,有小数的话也就是0.5,故不考虑
}
*/
return 0;
}
*********************第二题**********************
#include <iostream>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<stack>
using namespace std;
typedef long long LL;
int main()
{
LL n;
cin >> n;
// string s;
for(int i=0; i<n; i++){
// getline(cin, s);
stack<int> s;
stack<char> t;
char a, b, c;
LL A, B, C, D;
// cin >> A >> a >> B >> b >> C >> c >> D;
cin >> A;
s.push(A);
//while(!s.empty())
for(int i=0; i<3; i++)
{
// cout << s.top() << endl;
cin >> a >> A;
if(a == '+' || a == '-'){
/* if(t.empty()){
t.push(a);
s.push(A);
}*/
//if(t.top() == '-' || t.top() == '+')
if(!t.empty()){
char c = t.top();
t.pop();
LL tmp = s.top();
s.pop();
LL tmp2 = s.top();
s.pop();
if(c == '-')
s.push(tmp2-tmp);
else s.push(tmp2+tmp);
}
t.push(a);
s.push(A);
// s.push(B);
}
/* if(a == '+' || a == '-'){
s.push(A);
// s.push(B);
t.push(a);
}
*/ else if(a == 'x'){
LL tmp = s.top();
s.pop();
s.push(tmp*A);
}
else if(a == '/'){
LL tmp = s.top();
s.pop();
s.push(tmp/A);
}
}
while(!t.empty()){
char c = t.top();
t.pop();
LL tmp = s.top();
s.pop();
LL tmp2 = s.top();
s.pop();
if(c == '-')
s.push(tmp2-tmp);
else s.push(tmp2+tmp);
// cout << s.top() << endl;
}
//cout << s.top() << endl;
if(s.top() == 24){
cout << "Yes" << endl;
}
else cout << "No" << endl;
}
return 0;
}
#include <iostream>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<stack>
using namespace std;
typedef long long LL;
int main()
{
LL n;
cin >> n;
// string s;
for(int i=0; i<n; i++){
// getline(cin, s);
stack<int> s;
stack<char> t;
char a, b, c;
LL A, B, C, D;
// cin >> A >> a >> B >> b >> C >> c >> D;
cin >> A;
s.push(A);
//while(!s.empty())
for(int i=0; i<3; i++)
{
cin >> a >> A;
if(a == '+' || a == '-'){
s.push(A);
// s.push(B);
t.push(a);
}
else if(a == 'x'){
LL tmp = s.top();
s.pop();
s.push(tmp*A);
}
else if(a == '/'){
LL tmp = s.top();
s.pop();
s.push(tmp/A);
}
}
while(!t.empty()){
char c = t.top();
t.pop();
LL tmp = s.top();
s.pop();
LL tmp2 = s.top();
s.pop();
if(c == '-')
s.push(tmp2-tmp);
else s.push(tmp2+tmp);
}
if(s.top() == 24){
cout << "Yes" << endl;
}
else cout << "No" << endl;
}
return 0;
}
/*
if(a == '+' || a == '-'){
if(t.empty()){
t.push(a);
s.push(A);
}
//if(t.top() == '-' || t.top() == '+')
else{
LL tmp = s.top();
s.pop();
LL tmp2 = s.top();
s.pop();
char c = t.top();
t.pop();
t.push(a);
if(c == '-')
s.push(tmp2-tmp);
else s.push(tmp2+tmp);
}
// s.push(B);
}
*/
/*
******************************************************************************************************************
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<algorithm>
using namespace std;
int main() {
int n, s1, l;
int m;
cin >> n >> s1 >> l;
int a[100];
string s[100];
for(int i=0; i<l; i++){
cin >> a[i] >> s[i];
}
cin >>m;
for(int i=0; i<m; i++){
int tmp;
cin >> tmp;
}
{
for(int i=1; i<=8*m; i++){
cout << s[0][i-1];
if(i%8 == 0){
cout << endl;
}
}
}
return 0;
}
***************************************************************************
#include <iostream>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<queue>
const int N = 10000+5;
using namespace std;
typedef long long LL;
struct Point{
char opt;
int dst;
};
int main()
{
int T, n;
cin >> T >> n;
for(int i=0; i<T; i++){
queue<Point> P[n];
for(int j=0; j<n; j++){
char c = 'S', TMP;
int tmp;
int cnt = 0;
while(c != '\n'){
cin >> TMP >> tmp;
c = getchar();
Point Tmp;
Tmp.opt = c;
Tmp.dst = tmp;
P[j].push(Tmp);
}
}
//开始比较
int cnt = 0;
int flag = 0;
for(int k=0; ; k=(k+1)%n){
if(P[k].empty()){
cnt++;
}
Point Tmp = P[k].front();
if(Tmp.opt == 'S'){
if(P[Tmp.dst].front().opt == 'R' && P[Tmp.dst].front().dst == k){
P[k].pop();
P[Tmp.dst].pop();
// k = 0;
continue;
flag= 1;
}
}
if(k == n-1){
if( flag == 0){
cout << 1 << endl;
break;}
else {
flag = 0;
}
}
if(cnt == n){
cout << 0 << endl;
break;
}
}
}
return 0;
}
*/
**********************************diwuti 0分*-**************************
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<algorithm>
using namespace std;
const int N = 1e4+5;
const int INF = 1e7;
int map[N][N], dist[N], n, m;
int flag[N];
int stick[N];
struct Node{
int u, step;
Node(){
u = 0;
step = 0;
};
Node(int a, int c){
u = a;
step = c;
}
bool operator <(const Node &b)const
{
return step > b.step;
}
};
void Dij(int st)
{
priority_queue<Node> q;
q.push(Node(st, 0));
memset(flag, 0, sizeof(flag));
for(int i=1; i<=n; i++){
dist[i] = INF;
}
dist[st] = 0;
while(!q.empty()){
Node it = q.top();
q.pop();
int t = it.u;
if(flag[t]){
continue;
}
flag[t] = 1;
for(int i=1; i<=n; i++){
if(!flag[i] && map[t][i] < INF){
if(dist[i] >dist[t]+map[t][i]){
dist[i] = dist[t]+map[t][i];
q.push(Node(i, dist[i]));
}
}
}
}
}
int main() {
int u, v, w, st, k;
scanf("%d%d%d", &n, &m, &k);
for(int i=1; i<=n; i++){
for(int j=1; j<=n; j++){
if(i != j)
map[i][j] = INF;
else map[i][j] = 0;
}
}
for(int i=1; i<=n; i++){
cin >> stick[i];
}
while(m--){
cin >> u >> v >> w;
map[v][u] = map[u][v] = min(map[u][v], w);
}
int i = 1;
Dij(i);
//qishjidian
for(int i=1; i <= n; i++){
Dij(i);
int fd[n];
/* for(int j=1; j<=n; j++){
cout <<dist[j] << " ";*/
int cnt = 0;
for(int j=1; j<=n; j++){
// cout << dist[j] << endl;
if(stick[j]){
fd[cnt++] = dist[j];
}
}
/* for(int j=0; j<cnt; j++){
cout <<fd[j] << " ";
}
cout << endl;
*/
sort(fd, fd+cnt);
int tmp = 0;
for(int j=0; j<k; j++){
if(fd[j] != INF)
tmp += fd[j];
else break;
}
cout << tmp << endl;
}
return 0;
}
7 6 2
1 0 1 0 1 1 0
1 4 1
1 2 3
2 4 4
2 3 5
2 5 7
6 7 5