Page 2 of 4

Posted: Mon Dec 05, 2005 6:09 am
by Darko
No, it says:
" No blank line should appear after the last number."

You are missing a newline at the end.

Darko

Posted: Tue Dec 13, 2005 11:27 pm
by Trust Noone
You must delete the first cout<<'\n';
Then enable the last //cout<<'\n';
Then change cout<<"TERM "<<a<<" is "; to cout<<"TERM "<<a<<" IS ";

oh ya!

Posted: Wed Dec 21, 2005 10:40 am
by Karthekeyan
such a silly mistake i made!!:-((

Posted: Wed Dec 21, 2005 1:46 pm
by mamun
Why don't you remove your code?

264 Output Limit Exceeded

Posted: Mon Jan 02, 2006 7:02 am
by xlvector
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;

class CountCantor
{
public:
int* solve(int pos);
};

int* CountCantor::solve(int pos)
{
int n = (int)((sqrt(1.0+8.0*pos)-1)/2.0);
int size = (int)(n*(n+1)/2);
int left = pos - size;
int *ret = new int[2];
if(left>0){
ret[1] = n + 2 - left;
ret[0] = left;
}
else{
ret[0] = n;
ret[1] = 1;
}
if((n%2==0 && left>0)||(n%2==1 && left==0)){
std::swap(ret[0],ret[1]);
}
return ret;
}

int main()
{
int n;
CountCantor CC;
int *ret;
while(true){
cin>>n;
ret = CC.solve(n);
cout<<"TERM "<<n<<" IS "<<ret[0]<<"/"<<ret[1]<<endl;
delete[] ret;
}
return 0;
}

What's wrong with my code , I got Output Limit Exceeded Error

This is my output

Posted: Mon Jan 02, 2006 7:04 am
by xlvector
1
TERM 1 IS 1/1
2
TERM 2 IS 1/2
3
TERM 3 IS 2/1
4
TERM 4 IS 3/1
5
TERM 5 IS 2/2
10
TERM 10 IS 4/1
20
TERM 20 IS 5/2
100
TERM 100 IS 9/6
1000
TERM 1000 IS 36/10
10000
TERM 10000 IS 12/130
100000
TERM 100000 IS 129/319

Posted: Mon Jan 02, 2006 4:59 pm
by mamun
When do you believe your program terminates? :P

Time Limit Exceeded 264!!! Help!!!

Posted: Tue Apr 25, 2006 11:34 am
by Pachy_4_Ever
...
....
....
CODE

Posted: Tue Apr 25, 2006 6:12 pm
by Moha
This problem has a very nice solution. Think about a math formula.

264 - simple questtion

Posted: Sat Jul 29, 2006 6:31 am
by noahuman
hi there
i have a very simple question to ask

in question 264, it says "[i]The input list contains a single number per line and will be terminated by end-of-file.", [/i]does this mean the input should be from the command line, or from a file (using C++)?

I've got the answers correct, but the system does not accept my program, plz give me some hints ..... much appriciation ! :)


best regards

Posted: Sat Jul 29, 2006 7:24 am
by mf
Your program should read input from the standard input. For example, in this way (C++):

Code: Select all

int n;
while (cin >> n) { <compute answer>; cout << answer << endl; }
or this (C):

Code: Select all

while (scanf("%d", &n) == 1) { ...; printf("%s\n", answer); }

264 WA

Posted: Sat Aug 12, 2006 4:09 am
by ldaniele
What's wrong in my code (that could be optimised)

#include<iostream>

//#define PROVA
#ifdef PROVA

#include<fstream>
using std::ofstream;
using std::ifstream;
//using std::cout;
ofstream cout("output.txt");
ifstream cin("input.txt");

#endif
#ifndef PROVA

using std::cin;
using std::cout;

#endif

inline void elaborate(int n){
int term=n;
int minus=1, diag=1;
while(n>minus){
n-=minus;
minus+=1;
diag++;
}
//minus ora rappresenta la riga su cui si trova(da 1)
int den=0;
if(diag%2==0){
den=diag-(n-1);
//n rimane com'

Posted: Sat Aug 12, 2006 4:39 am
by ldaniele
i've solved!
There was a problem with input!
I had to put a test of nullity after cin!

264 PE?

Posted: Thu Aug 31, 2006 8:15 pm
by Vexorian
The problem says "No blank line should appear after the last number." But when I try not to have a blank line after last output it tells me Presentation Error, if I make it have a blank line after the last output, my solution gets AC

Posted: Thu Mar 22, 2007 10:06 am
by jainal cse du
Why I am gettiong PE?
I have taken input & print output as

Code: Select all

while(scanf("%ld",&term) == 1)
{
       after calcultaing  result 
   
         printf("TERM %ld IS %ld / %ld\n",term,a,b);
}

My program take 7.258 sec to solve this problem.
But I have seen some people solve it 0.000 sec.


Can Anybody tell me What's the algorithm for this problem?