# 1002

## 代码

#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
const int maxn=1005;
struct aa{
int x,y;
int t;
}a[maxn];
bool cmp(aa a,aa b){
return a.t<b.t;
}
int main(){
int te;
cin>>te;
while(te--){
int n;
cin>>n;
for(int i=0;i<n;++i){
cin>>a[i].x>>a[i].y;
int c=100-a[i].x;
int cc=0;
if(c>0){
cc=c/a[i].x;
if((c%a[i].x)!=0)
cc++;
}
a[i].t=cc*a[i].y;
}
double ans=0;
sort(a,a+n,cmp);
int cc=a[0].t;
int c=1;
while(a[c].t==cc&&c<n)
c++;
ans=1-c*1.0/(2.0*n);
printf("%.6lf\n",ans);
}
return 0;
}



# 1005

## 代码

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=4e5+10;
const ll inf=1e18;
int n,m,s,t,cost;
string ss;
struct node {
int u;
int v;
int w;
int next;
}edge[maxn*8];
int tol=0;
void addedge (int u,int v,int w) {
edge[tol].u=u;
edge[tol].v=v;
edge[tol].w=w;

edge[tol].u=v;
edge[tol].v=u;
edge[tol].w=w;
}
ll d[maxn];
int visit[maxn];
char wjm[maxn];
struct qnode {
int v;
ll w;
bool operator < (const qnode &r) const {
return w>r.w;
}
};
void dij (int s) {
memset(visit,0,sizeof(visit));
for (int i=1;i<=2*n;i++) d[i]=inf;
priority_queue<qnode> q;
d[s]=0;
q.push({s,0});
qnode tmp;
while (!q.empty()) {
tmp=q.top();
q.pop();
int u=tmp.v;
if (visit[u]) continue;
visit[u]=1;
int v=edge[i].v;
int tt;
if (wjm[u]==wjm[v])
tt=0;
else
tt=1;
if (!visit[v]&&d[v]>d[u]+edge[i].w+tt*cost) {
d[v]=d[u]+edge[i].w+tt*cost;
//if (!visit[v]) {
q.push({v,d[v]});
//visit[v]=1;
//}
}
}
}
}
int main () {
int T;
scanf("%d",&T);
while (T--) {
scanf("%d%d%d%d%d",&n,&m,&s,&t,&cost);
cin>>ss;

for (int i=1;i<=n;i++) {
if (ss[i-1]=='L') {
wjm[i]='L';
wjm[i+n]='L';
}
else if (ss[i-1]=='R') {
wjm[i]='R';
wjm[i+n]='R';
}
else {
wjm[i]='L';
wjm[i+n]='R';
}
}
tol=0;
for (int i=0;i<m;i++) {
int u,v,w;
scanf("%d%d%d",&u,&v,&w);
}
ll ans=1e18;
dij(s);
ans=min(ans,d[t]);
ans=min(ans,d[t+n]);
dij(s+n);
ans=min(ans,d[t]);
ans=min(ans,d[t+n]);
printf("%lld\n",ans);
}
return 0;
}



# 1011

## 代码

#include<bits/stdc++.h>
#define pb(a) push_back(a)
#define ms(x,y) memset(x,y,sizeof(x))
#define sci(a) scanf("%d",&a)
#define scl(a) scanf("%lld",&a)
#define scd(a) scanf("%lf",&a)
#define ll long long
using namespace std;
/* --------------- fast io --------------- */ // begin
const int SIZE=1<<20;
char buf[SIZE],*S,*T;
inline char getchar(){
if(S==T){
if(S==T)return EOF;
}
return *S++;
}
namespace Fwrite{
const int SIZE=1<<20;
char buf[SIZE],*S=buf,*T=buf+SIZE;
inline void flush(){
fwrite(buf,1,S-buf,stdout);
S=buf;
}
inline void putchar(char c){
*S++=c;
if(S==T)flush();
}
struct _{
~_(){flush();}
}__;
}//namespace Fwrite

#ifdef ONLINE_JUDGE
#define putchar Fwrite::putchar
#endif

x=0;int f=1;
char c=getchar();
while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
while(isdigit(c))x=x*10+(c-'0'),c=getchar();
x*=f;
}
template<typename T>inline void write(T x,bool _enter=0,bool _space=0){
if (!x)putchar('0');else{
if(x<0)putchar('-'),x=-x;
static char dig[41];
int top=0;
while(x)dig[++top]=(x%10)+'0',x/=10;
while(top)putchar(dig[top--]);
}
if(_enter)putchar('\n');
if(_space)putchar(' ');
}

namespace Fastio{
c=getchar();
while(c=='\n'||c==' ')c=getchar();
return *this;
}
int len=0;
char c=getchar();
while(c=='\n'||c==' ')c=getchar();
while(c!='\n'&&c!=' ')str[len++]=c,c=getchar();
str[len]='\0';
return *this;
}
}cin;
const char endl='\n';
struct writer{
template<typename T>writer& operator<<(T x){::write(x,0,0);return *this;}
writer& operator<<(char c){putchar(c);return *this;}
writer& operator<<(const char* str){
int cur=0;
while(str[cur])putchar(str[cur++]);
return *this;
}
}cout;
}//namespace Fastio
#define cin Fastio::cin
#define cout Fastio::cout
#define endl Fastio::endl
/* --------------- fast io --------------- */ // end

int main(){
int te;
cin>>te;
while(te--){
int a,b,c,d;
cin>>a>>b>>c>>d;
cout<<c<<endl;

}
return 0;
}

• 点赞
• 评论
• 分享
x

海报分享

扫一扫，分享海报

• 收藏
• 手机看

分享到微信朋友圈

x

扫一扫，手机阅读

• 打赏

打赏

For the brave

你的鼓励将是我创作的最大动力

C币 余额
2C币 4C币 6C币 10C币 20C币 50C币
• 一键三连

点赞Mark关注该博主, 随时了解TA的最新博文

07-24 97
09-01 795
08-06 107
08-02 35
12-29 448