HDU 섹션 4 문제 해결:
참조 코드:
#include<stack>
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<char,int>pii;
const int maxn=2e5+5;
const int eps=1e-6;
struct shudui
{
double a,d;
}m[maxn];
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n;
scanf("%d",&n);
for(int i=1;i<=n;++i)
{
scanf("%lf%lf",&m[i].a,&m[i].d);
}
double temp=1.0/(n*1.0);
double temp_pai=temp/2.0;
double ans=temp_pai;
for(int i=1;i<=n;++i)
{
double result=temp_pai;
for(int j=1;j<=n;++j)
{
if(j==i) continue;
int tt1=0,tt2=0,live=100;
while(live>0)
{
live-=m[i].a;
if(live<=0) break;
tt1+=m[i].d;
}
live=100;
while(live>0)
{
live-=m[j].a;
if(live<=0) break;
tt2+=m[j].d;
}
if(tt1==tt2)
{
result+=temp_pai;
}
else if(tt1<tt2)
result+=temp;
}
if(result-ans>eps) ans=result;
}
printf("%lf
",ans);
}
return 0;
}
1011: 이 장면에서 가장 간단한 문제지만 사람을 위협한다. 경험이 풍부하지 않을 수도 있다. 나와mh팀원들은 어떻게 구하는지 토론을 했지만 생각해 내지 못했다. 이후에 나는 데이터의 정밀도 A에 성공했다. 분명히 이런 데이터 범위는 믿을 만한 데이터를 아무렇게나 찾아서 날아갈 수 있다.
참조 코드:
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <math.h>
using namespace std;
typedef long long ll;
const int N = 1e3 + 5;
const int maxn = 1e5 + 5;
map<string, int> mp;
int pre[maxn], vis[30];
//char dp[maxn];
vector<ll> vec;
// typedef pair p;
// stack q;
// int a[maxn], sum[maxn];
// char pc[maxn];
// char s[maxn];
int dp[maxn][10], cnt;
struct node
{
double a, b;
} p[maxn];
bool check(double a, double b, double c, double d)
{
double q1 = 0, q2 = 0, e = 100, f = 100;
while (e > 0 && f > 0)
{
if (q1 == 0)
e -= a, q1 = b;
if (q2 == 0)
f -= c, q2 = d;
q1--, q2--;
}
if ((e <= 0 && f <= 0) || (e > 0))
return true;
}
int main()
{
// ios::sync_with_stdio(false);
// cin.tie(0);
double g = 6.67430, ans = 0.00000000001;
g *= ans;
int t;
cin >> t;
while (t--)
{
double a, b, d, m, c, k;
cin >> a >> b >> d >> m;
c = d;
if (a > b)
k = a;
else
k = b;
d = (double(1.0) / d / k) * (double(1.0) / d / k);
m *= m;
double dis1 = double(0.5) * (g * a * d * double(4.0)) * m;
double dis2 = double(0.5) * (g * b * d * double(4.0)) * m;
printf("%.11lf
", c - dis1 - dis2);
}
}
1004 이 문제는 피박나절한 문제이다. 처음에는 생각지도 못했다. 중간에mh가 언급했다. 나는 자세히 생각하지 않았다. 나는 그의 코드가 가능하다고 생각했다. 그리고 그에게 제출하라고 했다. 그리고wa를 생각하지 못했다. 그리고 나는 이 방면을 생각하지 않았다. 이후에 나는 조합수 역원을 구하는 것을 생각했다. 분명히 옳지 않았다. 마지막 몇 분 동안 포기하려고 할 때 잘못된 코드를 훑어보았을 때mh 코드를 보고wa점을 발견했다.수정 A 참조 코드:
#include <stack>
#include <queue>
#include <map>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const ll maxn = 2e5 + 5;
const ll mod = 1000000007;
ll fac[maxn];
ll inv[maxn];
ll n;
string a[maxn];
ll dp[maxn];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
ll t;
cin >> t;
while (t--)
{
cin >> n;
ll ans = 0;
memset(dp, 0, sizeof(dp));
for (ll i = 1; i <= n; i++)
cin >> a[i];
for (ll i = 2; i <= n; i++)
{
if (a[i] == a[i - 1])
dp[i] = dp[i - 1];
else
dp[i] = (dp[i - 1] + dp[i - 2] + 1) % mod;
}
cout << dp[n] + 1 << endl;
}
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.