11944 - $ 10 to Win?

All about problems in Volume 119. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
Eather
New poster
Posts: 28
Joined: Thu Jan 28, 2010 2:23 pm

11944 - $ 10 to Win?

Post by Eather »

Why Im getting WA??? During contest time, I was also getting WA... But couldn't find any mistakes... would some one plz help me???

Code: Select all

                           /*in the name of Allah */


# include <list>
# include <deque>
# include <bitset>
# include <algorithm>
# include <functional>
# include <numeric>
# include <utility>
# include <sstream>
# include <iostream>
# include <iomanip>
# include <cstdio>
# include <cmath>
# include <cstdlib>
# include <ctime>
# include <set>
# include <map>
# include <cmath>
# include <queue>
# include <limits>
# include <stack>
# include <vector>
# include <cstring>
# include <cstdio>
using namespace std;

# define MEM(array,w)   memset(array,w,sizeof array)
# define fr(i,a,b) for(int (i) = a ; i < b ; i++)
# define SET set<int>::iterator it = s.begin(); it != s.end();it++
# define ULL unsigned long long
# define eps 1e-9
# define SS stringstream
# define PR pair<int , int>
# define all(c) (c).begin(), (c).end()
# define maxint 1 << 31 - 1
# define FOR(i, a, b) for (int i=a; i<b; i++)
# define REP(i, a) FOR(i, 0, a)
# define rive(s) reverse(s.begin(),s.end())
# define OK(R,C) if(i>=0 && j>=0 && j<=C && i<=R)

template<class T> string toString(T n){ostringstream ost;ost<<n;ost.flush();return ost.str();}

int toInt(string s){int r=0;istringstream sin(s);sin>>r;return r;}

bool isprime(int n){if( n<2) return 0;for( int i=2; i*i<=n ; i++)if(n%i==0)return 0; return 1;return 0;}

int pel(string s){string t;t=s;reverse(t.begin(),t.end());if(s==t)return 1;return 0;}


int main()
{

long int weg;
cin>>weg;
long int we=weg;
int ca=0;
while(weg--)
{
  int bet, bett=0, count;

  cin>>bet>>count;
  bett=bet;
  double res2=0.0;

  for(int i=0;i<count;i++)
  {
    long int taka;
    cin>>taka;
    long double am;
    if(taka<0)am=(100.00/(long double)(taka*(-1)));
    else am=((long double)taka/100.00);
    int res=0;
    res= ceil(((long double)bett* (long double)am));
    bett+= ceil(((long double)res));
    res2+= res;
    //cout<<am<<" "<<res<<" "<<bett<<" "<<res2<<endl;
  }

  string s= toString(res2+bet);
  string ress="";

  rive(s);

  for(int i=0;i<s.size();i++)
  {
    ress+=s[i];
    if(i>0 && i%3==2 && i!=s.size()-1)ress+=",";
  }
  rive(ress);
  printf("%d $",++ca);
cout<<ress<<".00"<<endl;

}
return 0;

}
"akhono try kore jai"

sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

Re: 11944: $ 10 to Win?

Post by sohel »

Did you consider the case when the total value becomes > 1 million?

jurajz
Learning poster
Posts: 69
Joined: Sat Sep 02, 2006 7:30 pm
Location: Slovakia

Re: 11944: $ 10 to Win?

Post by jurajz »

Hello,

I have many WA's in this problem and I don't want make a guesses many more, I have question about "More than 1 million rule" (= if the value is above 1000000, that return 1000000). When should I apply this rule? Only in the end of computation ("Total returned"), and/or by every single Wager (second column of table in problem description), and/or by every Amount Won (forth column of table in problem description), or/and by making sum (row-by-row) of Total Returned? I tried many combination of this and I had always WA :-(

I hope, that I wrote it understandly.

Thanks in advance!

sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

Re: 11944: $ 10 to Win?

Post by sohel »

I just considered it at the end of the computation.

Eather
New poster
Posts: 28
Joined: Thu Jan 28, 2010 2:23 pm

Re: 11944: $ 10 to Win?

Post by Eather »

sorry Sohel via, I didn't post the right code.... the code is actually...

Code: Select all

                           /*in the name of Allah */


# include <list>
# include <deque>
# include <bitset>
# include <algorithm>
# include <functional>
# include <numeric>
# include <utility>
# include <sstream>
# include <iostream>
# include <iomanip>
# include <cstdio>
# include <cmath>
# include <cstdlib>
# include <ctime>
# include <set>
# include <map>
# include <cmath>
# include <queue>
# include <limits>
# include <stack>
# include <vector>
# include <cstring>
# include <cstdio>
using namespace std;

# define MEM(array,w)   memset(array,w,sizeof array)
# define fr(i,a,b) for(int (i) = a ; i < b ; i++)
# define SET set<int>::iterator it = s.begin(); it != s.end();it++
# define ULL unsigned long long
# define eps 1e-9
# define SS stringstream
# define PR pair<int , int>
# define all(c) (c).begin(), (c).end()
# define maxint 1 << 31 - 1
# define FOR(i, a, b) for (int i=a; i<b; i++)
# define REP(i, a) FOR(i, 0, a)
# define rive(s) reverse(s.begin(),s.end())
# define OK(R,C) if(i>=0 && j>=0 && j<=C && i<=R)

template<class T> string toString(T n){ostringstream ost;ost<<n;ost.flush();return ost.str();}

int toInt(string s){int r=0;istringstream sin(s);sin>>r;return r;}

bool isprime(int n){if( n<2) return 0;for( int i=2; i*i<=n ; i++)if(n%i==0)return 0; return 1;return 0;}

int pel(string s){string t;t=s;reverse(t.begin(),t.end());if(s==t)return 1;return 0;}


int main()
{

long int weg;
cin>>weg;
long int we=weg;
int ca=0;
while(weg--)
{
  int bet, bett=0, count;

  cin>>bet>>count;
  bett=bet;
  long int res2=0.0;

  for(int i=0;i<count;i++)
  {
    long double  taka;
    cin>>taka;

    //if(taka>1000000.00)taka=1000000.00;
    char ss[1001];
    long double am;
    if(taka<0)am=(100.00/(taka*(-1)));
    else am=(taka /100.00);
    printf(ss,"%.3lf",am);
    sscanf(ss,"%.3lf",&am);
    long int res=0;
    res= ceil(bett*(am));
    if(res>1000000.00)res=1000000.00;
    bett+= ceil(res);
    res2+= res;
   // cout<<am<<" "<<res<<" "<<bett<<" "<<res2<<endl;
  }
  //res2=100000012;
res2+=bet;
  if(res2>1000000)res2=1000000;



  string s= toString(res2);
  string ress="";

  rive(s);

  for(int i=0;i<s.size();i++)
  {
    ress+=s[i];
    if(i>0 && i%3==2 && i!=s.size()-1)ress+=",";
  }
  rive(ress);
  printf("%d $",++ca);cout<<ress<<".00"<<endl;

}
return 0;

}
Still getting WA... But dont know why is that. :( Help me plz.....

robot
New poster
Posts: 29
Joined: Sun May 24, 2009 8:39 pm

11944: $ 10 to Win?

Post by robot »

Can anyone tell what I am wrong..i cannot find any case to bug my code.....Here is my code..

#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <set>
#include <cmath>
#include <cstring>

#include <stdio.h>
#include <string.h>
#include <sstream>
#include <stdlib.h>
#include <vector>
#include <iomanip>
#include <ctime>
#include <numeric>
using namespace std;

#ifdef __GNUC__
typedef long long ll;typedef unsigned long long ull;
#else
typedef __int64 ll; typedef unsigned __int64 ull;
#pragma warn -csu
#endif



#define INF 1<<28
#define SIZE 100
#define ERR 1e-9
#define PI 3.141592653589793

#define REP(i,n) for (i=0;i<n;i++)
#define REV(i,n) for (i=n;i>=0;i--)

char ss[100];
int main()
{
int t,wage,num,n,cas=1,i,j;
double taka,r,to;
scanf("%d",&t);
while(t--)
{
scanf("%d %d",&wage,&num);
to=wage;
for(i=0;i<num;i++)
{
scanf("%d",&n);
if(n<0) taka= (100.0/(abs(n)));
else taka=(n/100.0);
r=ceil(wage*taka);
to+=r;
wage+=r;
}

if(to>=1000000) printf("%d $1,000,000.00\n",cas++);
else
{
i=j=0;
int too=to;
sprintf(ss,"%d",too);
int len=strlen(ss);
if(len>3) i=1;
printf("%d $",cas++);
for(int k=0;k<len;k++)
{
if(i && (len-3)==k) printf(",");
printf("%c",ss[k]);
}
printf(".00\n");
//printf("%s\n",ss);
}

}

return 0;
}
:x
Thanks Advance..

Post Reply

Return to “Volume 119 (11900-11999)”