- #include<bits/stdc++.h>
- #define x 1.0673956817111818692592637626711
- using namespace std;
- int main()
- {
- double a;
- while(scanf("%lf", &a)!=EOF){
- printf("%0.10lf\n",a*x);
- }
- return 0;
- }
Friday, 13 July 2018
uva problem 10286 Trouble with a Pentagon solution
uva problem 0260 Soundex solution
- #include<bits/stdc++.h>
- #include<string.h>
- using namespace std;
- int main()
- {
- char str[25];
- while(cin>>str){
- int f=0,s=0,t=0,fr=0,fi=0,si=0;
- for(int i=0;i<strlen(str);i++){
- if((str[i]=='B' || str[i]=='F' || str[i]=='P' || str[i]=='V' )){
- if(str[i-1]!='B' && str[i-1]!='F' && str[i-1]!='P' && str[i-1]!='V')
- cout<<"1";
- }
- if(str[i]=='C' || str[i]=='G' || str[i]=='J' || str[i]=='K' || str[i]=='Q' || str[i]=='S' || str[i]=='X' || str[i]=='Z' ){
- if(str[i-1]!='C' && str[i-1]!='G' && str[i-1]!='J' && str[i-1]!='K' && str[i-1]!='Q' && str[i-1]!='S' && str[i-1]!='X' && str[i-1]!='Z' )
- {
- cout<<"2";
- }
- }
- if (str[i]=='D' || str[i]=='T'){
- if (str[i-1]!='D' && str[i-1]!='T')
- cout<<"3";
- }
- if( str[i]=='L' ){
- if( str[i-1]!='L' )
- cout<<"4";
- }
- if(str[i]=='M' || str[i]=='N'){
- if(str[i-1]!='M' && str[i-1]!='N')
- cout<<"5";
- }
- if(str[i]=='R'){
- if(str[i-1]!='R')
- cout<<"6";
- }
- }
- cout<<endl;
- }
- return 0;
- }
uva problem 10252 Common Permutation solution
- #include<bits/stdc++.h>
- #include<string.h>
- #include<ctype.h>
- #include<algorithm>
- #include<sstream>
- #include<string>
- using namespace std;
- int main()
- {
- string str, st;
- while(getline(cin,str)){
- getline(cin, st);
- int strln= str.size();
- int stln= st.size();
- sort(str.begin(), str.end());
- sort(st.begin(), st.end());
- if( str == st) {
- cout<<str<<endl;
- continue;
- }
- for(int i=0,j=0; i<strln && j<stln; ){
- if(str[i] == st[j]) {
- cout<<str[i];
- i++;
- j++;
- }
- else {
- while(str[i]<st[j]){
- i++;
- if(i==strln)break;
- }
- while(st[j]<str[i]){
- j++;
- if(j==stln)break;
- }
- }
- }
- cout<<endl;
- }
- return 0;
- }
uva problem 10226 Hardwood Species solution
- #include<bits/stdc++.h>
- #include<algorithm>
- #include<string>
- #include<vector>
- #include <map>
- using namespace std;
- int main()
- {
- int t;
- scanf("%d", &t);
- getchar();
- getchar();
- while(t--) {
- map<string, int> record;
- string tree;
- int n = 0;
- while(getline(cin, tree)) {
- if(tree.compare("") == 0)
- break;
- record[tree]++;
- n++;
- }
- for(map<string, int>::iterator i = record.begin(); i != record.end(); i++)
- cout << i->first << " " << fixed << setprecision(4) << i->second*100.0/n << endl;
- if(t)
- puts("");
- }
- 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 ; ...