- #include<bits/stdc++.h>
- #include<vector>
- #include<algorithm>
- using namespace std;
- int main()
- {
- int num,t,n;
- vector<int> ss;
- cin>>t;
- while(t--){
- cin>>num;
- for(int i=1;i<=num;i++){
- cin>>n;
- ss.push_back(n);
- }
- sort(ss.begin(), ss.end());
- int sum;
- sum=ss[ss.size()-1]- ss[0];
- cout<<sum*2<<endl;
- ss.clear();
- }
- return 0;
- }
Sunday, 18 November 2018
uva problem 11364 Parking solution
uva problem 11192 Group Reverse solution
- #include<bits/stdc++.h>
- #include<string>
- using namespace std;
- int main()
- {
- int num,ln;
- string str;
- char st[1001],r[1001];
- while(cin>>num && num!=0){
- cin>>str;
- ln=str.length();
- int div,k=0;;
- div=ln/num;
- int d=0;
- for(int i=0;i<str.length();i++){
- if(d==div){
- for(int j=d-1;j>=0;j--) st[k++]=r[j];
- d=0;
- r[d++]=str[i];
- }
- else {
- r[d++]=str[i];
- }
- }
- for(int j=d-1;j>=0;j--) st[k++]=r[j];
- for(int i=0;i<k;i++) cout<<st[i];
- cout<<endl;
- }
- return 0;
- }
uva problem 11152 Colourful Flowers solution
- #include<bits/stdc++.h>
- #include<cmath>
- using namespace std;
- int main()
- {
- double a,b,c,s,r,red,rr,v,R;
- while(cin>>a>>b>>c){
- s=a+b+c;
- s=s/2;
- rr=sqrt(s*(s-a)*(s-b)*(s-c));
- r=rr/s;
- red=acos(-1);
- red=red*r*r;
- v=rr-red;
- R=(a*b*c)/(4*rr);
- R=acos(-1)*R*R;
- R=R-rr;
- printf("%0.4lf %0.4lf %0.4lf\n",R,v,red);
- }
- return 0;
- }
uva problem 11057 Exact Sum solution
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int arr[10005];
- int n,m,mi,d;
- while(cin>>n){
- mi=1000001;
- int x,y;
- for(int i=0;i<n;i++){
- cin>>arr[i];
- }
- cin>>m;
- for(int i=0;i<n-1;i++){
- for(int j=i+1;j<n;j++){
- if((arr[i]+arr[j])==m){
- d=(arr[i]>arr[j]?arr[i]-arr[j]:arr[j]-arr[i]);
- if(d<mi){
- mi=d;
- x=arr[i];
- y=arr[j];
- }
- }
- }
- }
- if(x>y){
- int t;
- t=x;
- x=y;
- y=t;
- }
- cout<<"Peter should buy books whose prices are "<<x<<" and "<<y<<".\n\n";
- }
- return 0;
- }
uva problem 10945 Mother bear solution
- #include<bits/stdc++.h>
- #include<string.h>
- #include<string>
- using namespace std;
- int main()
- {
- char str[100000],r[100000],cas[100000];
- while(gets(str)){
- int j=0;
- if(strcmp(str,"DONE")==0) break;
- for(int i=0;i<strlen(str);i++){
- if(isalpha(str[i])) r[j++]= str[i];
- }
- for(int i=0;i<j;i++) {
- if(r[i]>='a' && r[i]<='z') r[i]=r[i]-32;
- }
- for(int i=0;i<j;i++)
- {
- cas[j-1-i]=r[i];
- }
- int c=0;
- for(int i=0;i<j;i++){
- if(cas[i]==r[i]) c++;
- }
- if(c==j) cout<<"You won't be eaten!\n";
- else cout<<"Uh oh..\n";
- }
- return 0;
- }
Subscribe to:
Comments (Atom)
variable declaration of c program
#include <stdbool.h> #include<bits/stdc++.h> #include <stdio.h> #include <string.h> #include <std...
-
#include<bits/stdc++.h> #include<cmath> #include<algorithm> #define mx 20000005 using namespace std ; ...
-
#include<stdio.h> #include<string.h> int main ( void ) { char y [ 100001 ] ; int m4,m100,m400,m15...
-
#include<bits/stdc++.h> using namespace std ; int main ( ) { int arr [ 10005 ] ; int n,m,mi,d ; ...