Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct imput {
- short T;
- short K;
- };
- int main() {
- short P, N;
- cin >> P>> N;
- imput *Vector = new imput [P];
- for (short i=0;i<P;i++){
- cin >>Vector[i].T >>Vector[i].K;
- }
- short *suma = new short[P];
- suma[0]= Vector[0].T;
- for (short i=1; i<P; i++){
- suma[i]=0;
- for(short vec=0; vec<=i; vec++){
- suma[i]+= Vector[i].T;
- if( Vector[vec].T == Vector[i].T) {
- suma[i]+= Vector[vec].T + Vector[i].T;
- }
- cout << suma[i];
- cout << endl;
- }
- }
- return 0;
- }
- ////Problema3
- #include <iostream>
- using namespace std;
- struct Input{
- int K;
- int X;
- };
- int Collatz (int x){
- int f;
- if(x%2!=0) {
- f=(3*x)+1;
- }
- else if(x%2==0){
- f=(x/2);
- }
- return f;
- }
- int main (){
- int f=0, T;
- cin >>T;
- Input *p= new Input[T];
- for(int i=0; i < T; i++){
- cin >> p[i].K >> p[i].X;
- }
- cout << endl;
- for (int i=0; i< T; i++){
- for (int j=0 ; j<=p[i].K; j++){
- f = Collatz(p[i].X);
- p[i+1].X=f ;
- }
- cout << f << endl;
- }
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement