Example:

pattern: [name] [last_name]: [address], [city]

Word in [] is a tag, which will be replaced by the word from object User.

Object User has property Name, LastName, Address, City.

advised, would somebody please how? Thanks. ]]>

Code :

public void render(Sprite sprite, Transform transform, boolean offset) {
float rawX = transform.getPosition().getX() - (offset ? offsetVector.getX() : 0);
float rawY = transform.getPosition().getY() - (offset ? offsetVector.getY() : 0);
float scaleX = transform.getScale().getX();
float scaleY = transform.getScale().getY();
double rad = Math.toRadians(transform.getRotation());
double sin = Math.sin(rad);
double cos = Math.cos(rad);
float centerX = (sprite.getWidth() / 2) * scaleX;
float centerY = (sprite.getHeight() / 2) * scaleY;
float AAScale = 2;
for (int y = 0; y < sprite.getHeight() * scaleY * AAScale; y++) {
float yPos = y / AAScale - centerY;
float truePixelY = y / scaleY / AAScale;
for (int x = 0; x < sprite.getWidth() * scaleX * AAScale; x++) {
float xPos = x / AAScale - centerX;
float truePixelX = x / scaleX / AAScale;
int xPosFinalized = (int) (rawX + cos * xPos - sin * yPos);
int yPosFinalized = (int) (rawY + sin * xPos + cos * yPos);
if (xPosFinalized < 0 || xPosFinalized >= w || yPosFinalized < 0 || yPosFinalized >= h) continue;
Vector2f truePixelPos = new Vector2f(truePixelX, truePixelY);
Vector2i pos1 = new Vector2i(Math.floor(truePixelX), Math.floor(truePixelY));
Vector2i pos2 = new Vector2i(Math.floor(truePixelX), Math.ceil(truePixelY));
Vector2i pos3 = new Vector2i(Math.ceil(truePixelX), Math.floor(truePixelY));
Vector2i pos4 = new Vector2i(Math.ceil(truePixelX), Math.ceil(truePixelY));
Vector2f difference1 = truePixelPos.sub(pos1);
Vector2f difference2 = truePixelPos.sub(pos2);
Vector2f difference3 = truePixelPos.sub(pos3);
Vector2f difference4 = truePixelPos.sub(pos4);
double weight1 = difference1.length();
double weight2 = difference2.length();
double weight3 = difference3.length();
double weight4 = difference4.length();
boolean include1 = (sprite.getPixel(pos1.getX(), pos1.getY()) % 0xFFFFFF) != 0x00;
boolean include2 = (sprite.getPixel(pos2.getX(), pos2.getY()) % 0xFFFFFF) != 0x00;
boolean include3 = (sprite.getPixel(pos3.getX(), pos3.getY()) % 0xFFFFFF) != 0x00;
boolean include4 = (sprite.getPixel(pos4.getX(), pos4.getY()) % 0xFFFFFF) != 0x00;
double fullWeight = weight1 * (include1 ? 1 : 0) +
weight2 * (include2 ? 1 : 0) +
weight3 * (include3 ? 1 : 0) +
weight4 * (include4 ? 1 : 0);
int color = (int)Math.sqrt( sprite.getPixel(pos1.getX(), pos1.getY()) * sprite.getPixel(pos1.getX(), pos1.getY()) * (weight1 / fullWeight) * (include1 ? 1 : 0) +
sprite.getPixel(pos2.getX(), pos2.getY()) * sprite.getPixel(pos2.getX(), pos2.getY()) * (weight2 / fullWeight) * (include2 ? 1 : 0) +
sprite.getPixel(pos3.getX(), pos3.getY()) * sprite.getPixel(pos3.getX(), pos3.getY()) * (weight3 / fullWeight) * (include3 ? 1 : 0) +
sprite.getPixel(pos4.getX(), pos4.getY()) * sprite.getPixel(pos4.getX(), pos4.getY()) * (weight4 / fullWeight) * (include4 ? 1 : 0));
if((color % 0xFFFFFF) != 0x00) pixels[xPosFinalized + yPosFinalized * w] = color;
}
}
}

I have this method for drawing a sprite to the screen. the problem is that when I draw a perfect cross, it the vertical bar seems to be shifted to the left. I imagine that this code is the problem, but if you need the other parts to look at the result, please ask :)

--- Update ---

Okay... I fixed it. There was a problem with the antialiasing algorithm, it made it look really weird. Oh well. ]]>

Let it be X set of integers. describe a data structure with linear size, based on Binary search tree, which supports the following

methods:

1. insertion(a) - insert new integer a to X.

2. search(k) - return the k largest size element in X (the element which exactly k-1 integers are bigger than it).

for each method- you can use at most o(h) memory, when h is the height of the tree.

so, I know how to solve this only with more than o(h) memory for the second method.

I think i need to add here two fields for each node at the tree that contains the number fo sub-trees that are bigger/smaller than it, but i dont know how to proceed from here.

Can you show me the way? ]]>

Quote:

Alex is attending a Halloween party with his girlfriend Silvia. At the party, Silvia spots a giant chocolate bar. If the chocolate can be served as only 1 x 1 sized pieces and Alex can cut the chocolate bar exactly K times, what is the maximum number of chocolate pieces Alex can cut and give Silvia?

The first line contains an integer T, the number of test cases. T lines follow.

Each line contains an integer K

T lines. Each line contains an integer that denotes the maximum number of pieces that can be obtained for each test case.

1<=T<=10

2<=K<=107

Chocolate needed to be served in size of 1 x 1 size pieces.

Alex can't relocate any of the pieces, nor can he place any piece on top of

Code :

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
static long Halloween_party(long k){
if(k %2 ==0)
return (k/2)*(k/2);
return (k/2)*(k/2+1);
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
for(int i = 0;i < t;i++){
long k = in.nextInt();
System.out.println(Halloween_party(k));
}
}
}

I can see how it works, and it is great. But how did he work that out? How do you go from looking at the problem to coming up with that answer? What is the process? ]]>