Jxufe_ Shanghai Invitational Audition

Source: Internet
Author: User
Tags acos

General said this situation, the state is not very good, during a variety of small error card for a long time, freopen () can not be used, but also drunk, a topic description has a problem, do not say, b question less consider a situation, G question to lose into yes,i problem thinking always have ah, but at that time has been mixed chaos chaos, Code can't write, J question less write a break, so many low-level mistakes, harm my card for a long time, fortunately, the last hour when the feeling gradually came back, a bug was transferred out

In the game, the water problem is really a big influence on the mood

Links: Http://acm.hust.edu.cn/vjudge/contest/view.action?cid=76940#overview

HUST 1583: Unit of length
A problem is too pit daddy, you have to convert to inches before you convert to feet.

#include <stdio.h> #include <math.h>const double eps=1e-6; int main () {int n;/* #ifndef online_judgefreopen ("In.txt", "R", stdin), #endif */while (scanf ("%d", &n)!=eof) {Double A =n;int b=n/3;if ((n%3) >1) b++;p rintf ("%d%d\n", b/12,b%12);}}

HUST 1584: Setting the table

To find out each small circle to occupy the circle of the center angle, connecting the center of the two circles, too large center for small round tangent, to find out the angle of each small circle accounted for the angle, and then a special sentence r>r situation

#include <stdio.h> #include <math.h>const double Pi=acos ( -1.0); const double eps=1e-8; int main () {//freopen ("In.txt", "R", stdin), int n;double r,r;while (scanf ("%d%lf%lf", &n,&r,&r)!=eof) { Double c=r-r;double b=r;int num;if (r>r) Num=0;else if (2*r>r) Num=1;else if (Fabs (2*r-r) <eps) num=2;else{double Q=asin (B/C) *2.0;num=floor (2.0*pi/q+eps);//printf ("%f%f\n", 2*pi,q);} if (n<=num) printf ("yes\n"), Else printf ("no\n");} return 0;}

HUST 1583: Queuing

The smaller values of b+1 and n-a can be obtained by drawing

#include <stdio.h> #include <algorithm>using namespace Std;int main () {/* #ifndef Online_judgefreopen (" In.txt "," R ", stdin), #endif */int n,a,b;while (scanf ("%d%d%d ", &n,&a,&b)!=eof) {printf ("%d\n ", Min (b+1,n-a ));} return 0;}

SCU 4424:permutations

The first hard in accordance with the principle of seeking, did not expect to directly in the law, the law is very simple, a[i]=i*a[i-1]+i

And then you can use a long long to mold it.

#include <stdio.h> #define MOD 1000000007typedef long long Ll;long long A[8000005];int main () {a[0]=0;for (int i=1;i& lt;=8000000;i++) {a[i]= (LL) i* (a[i-1]+1))%mod;} int t,n;scanf ("%d", &t), while (t--) {scanf ("%d", &n);p rintf ("%lld\n", A[n]%mod);}}

HUST 1622: Xiao Ming's triangle

Either side is greater than the third side, and then determine if it is in a straight line

#include <stdio.h> #include <math.h> #include <algorithm>using namespace Std;const double Pi=acos (- 1.0); const double eps=1e-8; struct point {double x, y; Point () {}point (double xx,double yy) {x=xx;y=yy;} Point operator-(point B) {return point (X-B.X,Y-B.Y),} double operator^ (point B) {return x*b.y-y*b.x;}; Double Dist (double x1,double y1,double x2,double y2) {return sqrt ((x1-x2) * (X1-X2) + (y1-y2) * (Y1-y2));} int main () {//freopen ("In.txt", "R", stdin);d ouble x1,x2,x3,y1,y2,y3;double r,r;int t;scanf ("%d", &t), while (t--) { scanf ("%lf%lf%lf%lf%lf%lf", &x1,&y1,&x2,&y2,&x3,&y3); Point P=point (X1,Y1); Point Q=point (X2,y2); Point R=point (x3,y3);d ouble a=dist (x1,y1,x2,y2);d ouble b=dist (x1,y1,x3,y3);d ouble c=dist (x2,y2,x3,y3); if (Fabs (p-q ^ (r-q)) <eps) printf ("no\n"); Else{if (a+b-eps>c| | a+c-eps>b| | B+c-eps>a) printf ("yes\n"), Else printf ("no\n");}}}

HUST 1646:

Here is the absolute maximum value, which is converted to the maximum and minimum value, if it is the absolute value of the minimum, then there is no way.

Dp[i]: Indicates the maximum or minimum value of the area ending with I, then

Dp[i]=max (Dp[i-1]+a[i],a[i])

Dp[i]=main (Dp[i-1]+a[i],a[i])

and scan it through the end.

#include <stdio.h> #include <algorithm> #include <stdlib.h>//dp[i]: Select the maximum value when using namespace std; struct Node{int Ma,mi;} Dp[100005];int A[100005],s[100005];int Main () {//freopen ("In.txt", "R", stdin); int N;while (scanf ("%d", &n)!=eof) { for (int i=1;i<=n;i++) scanf ("%d", &a[i]), and for (int i=1;i<=n;i++) s[i]+=s[i-1];DP [1].ma=a[1];DP [1].mi=a[1]; for (int i=2;i<=n;i++) {Dp[i].ma=max (dp[i-1].ma+a[i],a[i]);DP [I].mi=min (Dp[i-1].mi+a[i],a[i]);//printf ("%d", DP [I].MI);} int ans=0;for (int i=1;i<=n;i++) {Ans=max (Ans,abs (dp[i].ma)); Ans=max (Ans,abs (DP[I].MI));} printf ("%d\n", ans);} return 0;}

SCU 4416:happy hkw

According to the price from small to large order, then the first price must be large by the front, then only need to compare the quality of the first I is smaller than the maximum value of the previous quality

#include <stdio.h> #include <algorithm>using namespace std;struct node{int p,q;} A[100005];int CMP (Node A,node b) {return A.P<B.P;} int main () {//freopen ("In.txt", "R", stdin), int n;while (scanf ("%d", &n)!=eof) {for (int i=0;i<n;i++) scanf ("%d%d" , &a[i].p,&a[i].q); sort (a,a+n,cmp); int ma=a[0].q,flag=1;for (int i=1;i<n;i++) {if (a[i].q<ma) {flag=0; printf ("Happy xkw\n"); Ma=max (MA,A[I].Q);} if (flag) printf ("Poor xkw\n");} return 0;}


Jxufe_ Shanghai Invitational Audition

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.